|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcoderz.commons.util.FileUtils
public final class FileUtils
This class collects some nifty file utility functions. TODO: Cleanup check vs. IoUtil
| Method Summary | |
|---|---|
static void |
close(InputStream in)
Deprecated. use IoUtil.close(InputStream) |
static void |
close(OutputStream out)
Deprecated. use IoUtil.close(OutputStream) |
static void |
copy(File src,
File destinationDir)
Copies the file or directory src to the
directory destinationDir. |
static void |
copy(InputStream in,
OutputStream out)
Copy from an input stream to an output stream. |
static void |
copyFile(File src,
File dest)
Copies the file src to the file or directory
dest. |
static void |
copySlashStar(File srcDir,
File dst)
Copy all files under srcDir to the directory
dst. |
static void |
createNewFile(File newFile)
Creates the given file. |
static File |
createTempDir(File baseDir,
String prefix)
Creates a temporary directory. |
static void |
delete(File aFile)
Deletes the given file aFile. |
static List |
findFile(File path,
String pattern)
Search for files in a directory hierarchy. |
static String |
getRelativePath(File baseDir,
File file)
Returns the relative path of file to the file
basedir. |
static void |
mkdir(File dir)
Creates the given directory. |
static void |
mkdirs(File dirs)
Creates the given directories. |
static void |
rename(File aFile,
File dest)
Renames the file aFile. |
static void |
rmdir(File file)
Remove file or directory. |
static void |
safeClose(Reader reader)
Deprecated. use IoUtil.close(Reader) |
static void |
safeClose(Writer writer)
Deprecated. use IoUtil.close(Writer) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void copy(File src,
File destinationDir)
throws IOException
src to the
directory destinationDir.
src - the source file or directory.destinationDir - the destination directory.
IOException - in case of an I/O error.
public static void copyFile(File src,
File dest)
throws FileNotFoundException,
IOException
src to the file or directory
dest.
src - The source file.dest - The destination file or directory.
FileNotFoundException - if the source file does not exists.
IOException - in case of an I/O error.
public static void copy(InputStream in,
OutputStream out)
throws IOException
in - The input stream.out - The output stream.
IOException - when an error happens during a read or a write
operation.
public static void copySlashStar(File srcDir,
File dst)
throws IOException
srcDir to the directory
dst.
Unix command:
$ cp "$scrDir/*" "$dst"
srcDir - the source directory.dst - the destination directory.
IOException - in case of an I/O error.
public static File createTempDir(File baseDir,
String prefix)
throws IOException
baseDir - the base directory.prefix - prefix for the temporary directory.
IOException - in case of an I/O error.public static void close(InputStream in)
Level.FINE is logged. It's safe to pass a
null reference for the argument.
in - the input stream that should be closed.public static void close(OutputStream out)
Level.FINE is logged. It's safe to pass a
null reference for the argument.
out - the output stream that should be closed.public static void safeClose(Reader reader)
Level.FINE is logged. It's safe
to pass a null reference for the argument.
reader - the reader that should be closed.public static void safeClose(Writer writer)
Level.FINE is logged. It's safe
to pass a null reference for the argument.
writer - the writer that should be closed.
public static List findFile(File path,
String pattern)
find path -name pattern
path - root directory.pattern - filename pattern.
pattern
under path.
public static void rmdir(File file)
throws IOException
rm -rf file
file - the file or directory to delete.
IOException - in case of an I/O error.
public static String getRelativePath(File baseDir,
File file)
throws IOException
file to the file
basedir.
baseDir - the base directory or file.file - the file.
IOException - in case of an I/O error.
public static void rename(File aFile,
File dest)
throws IOException
aFile.
aFile - The file to be renamed.dest - The new abstract pathname for the named file
IOException - if the the renaming was not successful.
public static void delete(File aFile)
throws IOException
aFile.
aFile - The file to be deleted.
IOException - if the the deletion was not successful.
public static void mkdirs(File dirs)
throws IOException
dirs - the directories to be created.
IOException - the directories could not be created.File.mkdirs()
public static void mkdir(File dir)
throws IOException
dir - the directory to be created.
IOException - if the file could not be created.File.mkdir()
public static void createNewFile(File newFile)
throws IOException
newFile - the file to create
IOException - the file could not be created.File.createNewFile()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||