org.eclipse.actf.util

## Class FileUtils

- java.lang.Object
- - org.eclipse.actf.util.FileUtils

    public class FileUtils
    extends Object

### Field Summary

Fields
`static String` `LINE_SEP` Line separator.

### Constructor Summary

Constructors
Constructor and Description
`FileUtils()`

### Method Summary

Methods
`static boolean` `copyFile(org.osgi.framework.Bundle bundle, IPath file, String savePath, boolean overWrite)` Copy file in bundle to specified path
`static void` `copyFile(FileInputStream source, FileOutputStream dest)` copy a file
`static boolean` `copyFile(File source, String dest, boolean overWrite)` copy a file
`static boolean` `copyFile(String source, String dest, boolean overWrite)` copy a file
`static void` `copyFiles(File baseDir, File newParent, String pattern)` Copy files matching a certain pattern from one directory to another
`static void` `deleteFiles(File rootDir)` delete files or directories under the specified root directory
`static void` `deleteFiles(File baseDir, String pattern)` delete files or directories matching a specified pattern
`static void` `findFiles(FilenameFilter filter, File baseDir, List<File> fileList)` Find files matching a specified pattern in a specified location
`static File[]` `findFiles(String fileDesc, File baseDir)` Find files matching a specified pattern in a specified location
`static String` `getActfTempDir()` Create the ACTF temporary directory which is a subdirectory of the value of java.io.tmpdir Checking is done to ensure a File.separator is added if needed.
`static boolean` `isAvailableDirectory(String path)` Confirm availability of the directory
`static String` `replaceWhiteSpaceInUrl(String target)` Replace white space " " in URL string with "%20"
`static boolean` `saveToFile(InputStream is, String savePath, boolean overWrite)` Save target input stream to specified path

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### LINE_SEP

    public static final String LINE_SEP

Line separator. (System.getProperty("line.separator"))

### Constructor Detail

#### FileUtils

    public FileUtils()

### Method Detail

#### replaceWhiteSpaceInUrl

    public static String replaceWhiteSpaceInUrl(String target)

Replace white space " " in URL string with "%20"

Parameters:
  `target` - the target URL String
Returns:
  replaced URL string

#### copyFile

    public static boolean copyFile(File source,
                   String dest,
                   boolean overWrite)

copy a file

Parameters:
  `source` - - the source File
  `dest` - - the destination file path in String
  `overWrite` - - allow to overwrite the existing file or not
Returns:
  file was copied or not

#### copyFile

    public static boolean copyFile(String source,
                   String dest,
                   boolean overWrite)

copy a file

Parameters:
  `source` - - the source file path in String
  `dest` - - the destination file path in String
  `overWrite` - - allow to overwrite the existing file or not
Returns:
  file was copied or not

#### copyFile

    public static void copyFile(FileInputStream source,
                FileOutputStream dest)
                         throws IOException

copy a file

Parameters:
  `source` - - the source file input stream
  `dest` - - the destination file output stream
Throws:
  `IOException`

#### copyFiles

    public static void copyFiles(File baseDir,
                 File newParent,
                 String pattern)

Copy files matching a certain pattern from one directory to another

Parameters:
  `baseDir` - - the directory to copy from - must be existing
  `newParent` - - the directory to copy to - must be existing
  `pattern` - - the pattern of files to copy

#### copyFile

    public static boolean copyFile(org.osgi.framework.Bundle bundle,
                   IPath file,
                   String savePath,
                   boolean overWrite)

Copy file in bundle to specified path

Parameters:
  `bundle` - the target bundle
  `file` - the target file path
  `savePath` - the target path to copy the file
  `overWrite` - allow to overwrite the existing file or not
Returns:
  file was copied or not

#### saveToFile

    public static boolean saveToFile(InputStream is,
                     String savePath,
                     boolean overWrite)

Save target input stream to specified path

Parameters:
  `is` - the target input stream
  `savePath` - the target path to store the file
  `overWrite` - allow to overwrite the existing file or not
Returns:
  file was saved or not

#### deleteFiles

    public static void deleteFiles(File rootDir)

delete files or directories under the specified root directory

Parameters:
  `rootDir` - - root directory from which to start - must be existing directory

#### deleteFiles

    public static void deleteFiles(File baseDir,
                   String pattern)

delete files or directories matching a specified pattern

Parameters:
  `baseDir` - - root directory from which to start - must be existing directory
  `pattern` - - the pattern of file names to erase

#### findFiles

    public static File[] findFiles(String fileDesc,
                   File baseDir)

Find files matching a specified pattern in a specified location

Parameters:
  `fileDesc` - - the filename pattern you are searching for
  `baseDir` - - the directory to search - must be existing
Returns:
  array of files

#### findFiles

    public static void findFiles(FilenameFilter filter,
                 File baseDir,
                 List<File> fileList)

Find files matching a specified pattern in a specified location

Parameters:
  `filter` - - filename filter of matching pattern
  `baseDir` - - the directory from which to start the search
  `fileList` - - a Linked List where the found files will be returned

#### isAvailableDirectory

    public static boolean isAvailableDirectory(String path)

Confirm availability of the directory

Parameters:
  `path` - target directory path
Returns:
  true if the target path is writable directory

#### getActfTempDir

    public static String getActfTempDir()

Create the ACTF temporary directory which is a subdirectory of the value of java.io.tmpdir Checking is done to ensure a File.separator is added if needed. This should be used by all components requiring the ACTF temp directory

Returns:
  a String representing the name of the directory