Skip navigation links

Oracle® WebCenter Content Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-03


oracle.stellent.wcm.common.io
Class FileUtils

java.lang.Object
  extended by oracle.stellent.wcm.common.io.FileUtils


public class FileUtils
extends java.lang.Object

Constructor Summary
FileUtils()
           

 

Method Summary
static boolean assureDirectoryExists(java.io.File dir, ILog log)
          Make sure that the directory exists, creating it if necessary
static boolean assureDirectoryExists(java.lang.String dirPath, ILog log)
          Make sure that the directory exists, creating it if necessary
static void copy(java.io.File src, java.io.File dst)
          Copies src file to dst file.
static java.io.File createTempDirectory(java.lang.String prefix, java.lang.String suffix, java.io.File parentDir)
           
static boolean deleteFileOrDirectory(java.io.File dir)
          Deletes all files and subdirectories under dir.
static java.lang.String getExtension(java.lang.String path)
           
static java.io.File getHashPath(java.lang.String dDocName, java.util.regex.Pattern dirHash)
          Return a directory path to the dDocName using the dirHash pattern.
static void moveFile(java.io.File source, java.io.File destination)
          Move the source file to the destination file
static java.lang.String readDirHashFile(java.io.File root)
          Read the dirHash Pattern in from the root directory.
static void renameFile(java.io.File fromFile, java.io.File toFile, boolean overwrite)
          Referenced from Content Server source; refer to intradoc.common.FileUtils#renameFileEx(java.lang.String, java.lang.String, int)
static java.io.File subtractRootPath(java.io.File rootPath, java.io.File fullPath)
          extract the part after the rootPath from the fullPath
static boolean validateFile(java.io.File file, boolean isDirectory)
          Validate a file before accessing.
static void writeDirHashFile(java.lang.String dirHash, java.io.File root)
          Write the string dirHash into a file "dirHash.txt" in the root directory if the text is null or blank, the file if present will be removed.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

FileUtils

public FileUtils()

Method Detail

validateFile

public static boolean validateFile(java.io.File file,
                                   boolean isDirectory)
Validate a file before accessing. Determines if the file exists, is readable and is a file object.
Parameters:
file - a reference to a physical file
isDirectory - if true, validate this is a directory; false validate this is a file
Returns:
true if the file exists and can be read

copy

public static void copy(java.io.File src,
                        java.io.File dst)
                 throws java.io.IOException
Copies src file to dst file. If the dst file does not exist, it is created
Parameters:
src -
dst -
Throws:
java.io.IOException

deleteFileOrDirectory

public static boolean deleteFileOrDirectory(java.io.File dir)
Deletes all files and subdirectories under dir. If a deletion fails, the method stops attempting to delete and returns false.
Parameters:
dir -
Returns:
Returns true if all deletions were successful.

assureDirectoryExists

public static boolean assureDirectoryExists(java.lang.String dirPath,
                                            ILog log)
Make sure that the directory exists, creating it if necessary
Parameters:
dirPath - directory path
log - ILog reference if logging is desired, if not desired pass in null
Returns:
true if exists, or was created, false if cannot create

assureDirectoryExists

public static boolean assureDirectoryExists(java.io.File dir,
                                            ILog log)
Make sure that the directory exists, creating it if necessary
Parameters:
dir - directory path
log - ILog reference if logging is desired, if not desired pass in null
Returns:
true if exists, or was created, false if cannot create

subtractRootPath

public static java.io.File subtractRootPath(java.io.File rootPath,
                                            java.io.File fullPath)
extract the part after the rootPath from the fullPath
Parameters:
rootPath - first part of path (ie: /scs/weblayout/)
fullPath - full path (ie: /scs/weblayout/groups/public/documents/adhr/)
Returns:
part after the rootPath (ie: groups/public/documents/adhr/)

getExtension

public static java.lang.String getExtension(java.lang.String path)

getHashPath

public static java.io.File getHashPath(java.lang.String dDocName,
                                       java.util.regex.Pattern dirHash)
Return a directory path to the dDocName using the dirHash pattern. In the pattern any areas surrounded by parenthesis are used to create directory levels
Parameters:
dDocName - Content Server's dDocName
dirHash - precompiled regular expression
Returns:

writeDirHashFile

public static void writeDirHashFile(java.lang.String dirHash,
                                    java.io.File root)
                             throws java.io.IOException
Write the string dirHash into a file "dirHash.txt" in the root directory if the text is null or blank, the file if present will be removed. By convention, you should set the root directory to be the parent of the metadata/content directory
Parameters:
dirHash - text to write into the file
root - directory where the "dirHash.txt" file is located
Throws:
java.io.IOException

readDirHashFile

public static java.lang.String readDirHashFile(java.io.File root)
                                        throws java.io.IOException
Read the dirHash Pattern in from the root directory. By convention, you should set the root directory to be the parent of the metadata/content directory
Parameters:
root - directory where the "dirHash.txt" file is located
Returns:
compiled Pattern or null
Throws:
java.io.IOException

moveFile

public static void moveFile(java.io.File source,
                            java.io.File destination)
                     throws java.io.IOException
Move the source file to the destination file
Parameters:
source - the source file
destination - the destination
Throws:
java.io.IOException

renameFile

public static void renameFile(java.io.File fromFile,
                              java.io.File toFile,
                              boolean overwrite)
                       throws java.io.IOException
Referenced from Content Server source; refer to intradoc.common.FileUtils#renameFileEx(java.lang.String, java.lang.String, int)
Parameters:
fromFile - the source file
toFile - the destination
overwrite - true to overwrite the destination if it exists
Throws:
java.io.IOException

createTempDirectory

public static java.io.File createTempDirectory(java.lang.String prefix,
                                               java.lang.String suffix,
                                               java.io.File parentDir)
                                        throws java.io.IOException
Throws:
java.io.IOException

Skip navigation links

Oracle® WebCenter Content Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-03


Copyright © 2010, 2011, Oracle and/or its affiliates. All rights reserved.