FileUtils (fawkeZ - Developer's Documentation)

org.jcoderz.commons.util
Class FileUtils

  extended by org.jcoderz.commons.util.FileUtils

public final class FileUtils
extends

This class collects some nifty file utility functions. TODO: Cleanup check vs. IoUtil

Author:
Michael Griffel, Andreas Mandel

Method Summary
static void close( in)
          Deprecated. use IoUtil.close(InputStream)
static void close( out)
          Deprecated. use IoUtil.close(OutputStream)
static void copy( src,  destinationDir)
          Copies the file or directory src to the directory destinationDir.
static void copy( in,  out)
          Copy from an input stream to an output stream.
static void copyFile( src,  dest)
          Copies the file src to the file or directory dest.
static void copySlashStar( srcDir,  dst)
          Copy all files under srcDir to the directory dst.
static  createTempDir( baseDir,  prefix)
          Creates a temporary directory.
static void delete( aFile)
          Deletes the given file aFile.
static  findFile( path,  pattern)
          Search for files in a directory hierarchy.
static  getRelativePath( baseDir,  file)
          Returns the relative path of file to the file basedir.
static void rename( aFile,  dest)
          Renames the file aFile.
static void rmdir( file)
          Remove file or directory.
static void safeClose( reader)
          Deprecated. use IoUtil.close(Reader)
static void safeClose( writer)
          Deprecated. use IoUtil.close(Writer)
 
Methods inherited from class java.lang.
, , , , , , , , , ,
 

Method Detail

copy

public static void copy( src,
                         destinationDir)
                 throws 
Copies the file or directory src to the directory destinationDir.

Parameters:
src - the source file or directory.
destinationDir - the destination directory.
Throws:
- in case of an I/O error.

copyFile

public static void copyFile( src,
                             dest)
                     throws ,
                            
Copies the file src to the file or directory dest.

Parameters:
src - The source file.
dest - The destination file or directory.
Throws:
- if the source file does not exists.
- in case of an I/O error.

copy

public static void copy( in,
                         out)
                 throws 
Copy from an input stream to an output stream.

Parameters:
in - The input stream.
out - The output stream.
Throws:
- when an error happens during a read or a write operation.

copySlashStar

public static void copySlashStar( srcDir,
                                  dst)
                          throws 
Copy all files under srcDir to the directory dst. Unix command:
 $ cp "$scrDir/*" "$dst"
 

Parameters:
srcDir - the source directory.
dst - the destination directory.
Throws:
- in case of an I/O error.

createTempDir

public static  createTempDir( baseDir,
                                  prefix)
                          throws 
Creates a temporary directory.

Parameters:
baseDir - the base directory.
prefix - prefix for the temporary directory.
Returns:
a temporary directory.
Throws:
- in case of an I/O error.

close

public static void close( in)
Deprecated. use IoUtil.close(InputStream)

Closes the input stream (safe). This method tries to close the given input stream and if an IOException occurs a message with the level is logged. It's safe to pass a null reference for the argument.

Parameters:
in - the input stream that should be closed.

close

public static void close( out)
Deprecated. use IoUtil.close(OutputStream)

Closes the output stream (safe). This method tries to close the given output stream and if an IOException occurs a message with the level is logged. It's safe to pass a null reference for the argument.

Parameters:
out - the output stream that should be closed.

safeClose

public static void safeClose( reader)
Deprecated. use IoUtil.close(Reader)

Closes the reader (safe). This method tries to close the given reader and if an IOException occurs a message with the level is logged. It's safe to pass a null reference for the argument.

Parameters:
reader - the reader that should be closed.

safeClose

public static void safeClose( writer)
Deprecated. use IoUtil.close(Writer)

Closes the writer (safe). This method tries to close the given writer and if an IOException occurs a message with the level is logged. It's safe to pass a null reference for the argument.

Parameters:
writer - the writer that should be closed.

findFile

public static  findFile( path,
                             pattern)
Search for files in a directory hierarchy. Unix command:
 find path -name pattern
 

Parameters:
path - root directory.
pattern - filename pattern.
Returns:
a list of files matching the given pattern under path.

rmdir

public static void rmdir( file)
                  throws 
Remove file or directory. Unix command:
 rm -rf file
 

Parameters:
file - the file or directory to delete.
Throws:
- in case of an I/O error.

getRelativePath

public static  getRelativePath( baseDir,
                                      file)
                              throws 
Returns the relative path of file to the file basedir.

Parameters:
baseDir - the base directory or file.
file - the file.
Returns:
the relative path of the file to the basedir.
Throws:
- in case of an I/O error.

rename

public static void rename( aFile,
                           dest)
                   throws 
Renames the file aFile.

Parameters:
aFile - The file to be renamed.
dest - The new abstract pathname for the named file
Throws:
- if the the renaming was not successful.

delete

public static void delete( aFile)
                   throws 
Deletes the given file aFile.

Parameters:
aFile - The file to be deleted.
Throws:
- if the the deletion was not successful.


Copyright 2007 The jCoderZ Project.