jodd.io
Class FileUtil

java.lang.Object
  extended by jodd.io.FileUtil

public class FileUtil
extends java.lang.Object

File utilities.


Field Summary
static FileUtilParams defaultParams
           
 
Constructor Summary
FileUtil()
           
 
Method Summary
static void appendBytes(java.io.File dest, byte[] data)
           
static void appendBytes(java.io.File dest, byte[] data, int off, int len)
           
static void appendBytes(java.lang.String dest, byte[] data)
           
static void appendBytes(java.lang.String dest, byte[] data, int off, int len)
           
static void appendString(java.io.File dest, java.lang.String data)
           
static void appendString(java.io.File dest, java.lang.String data, java.lang.String encoding)
           
static void appendString(java.lang.String dest, java.lang.String data)
           
static void appendString(java.lang.String dest, java.lang.String data, java.lang.String encoding)
           
static void cleanDir(java.io.File dest)
           
static void cleanDir(java.io.File dest, FileUtilParams params)
          Cleans a directory without deleting it.
static void cleanDir(java.lang.String dest)
           
static void cleanDir(java.lang.String dest, FileUtilParams params)
           
static FileUtilParams cloneParams()
          Creates new FileUtilParams instance by cloning current default params.
static boolean compare(java.io.File file1, java.io.File file2)
          Compare the contents of two files to determine if they are equal or not.
static boolean compare(java.lang.String file1, java.lang.String file2)
           
static void copy(java.io.File src, java.io.File dest)
           
static void copy(java.io.File src, java.io.File dest, FileUtilParams params)
          Smart copy.
static void copy(java.lang.String src, java.lang.String dest)
           
static void copy(java.lang.String src, java.lang.String dest, FileUtilParams params)
           
static void copyDir(java.io.File srcDir, java.io.File destDir)
           
static void copyDir(java.io.File srcDir, java.io.File destDir, FileUtilParams params)
          Copies directory with specified copy params.
static void copyDir(java.lang.String srcDir, java.lang.String destDir)
           
static void copyDir(java.lang.String srcDir, java.lang.String destDir, FileUtilParams params)
           
static void copyFile(java.io.File src, java.io.File dest)
           
static void copyFile(java.io.File src, java.io.File dest, FileUtilParams params)
          Copies a file to another file with specified copy params.
static void copyFile(java.lang.String src, java.lang.String dest)
           
static void copyFile(java.lang.String src, java.lang.String dest, FileUtilParams params)
           
static java.io.File copyFileToDir(java.io.File src, java.io.File destDir)
           
static java.io.File copyFileToDir(java.io.File src, java.io.File destDir, FileUtilParams params)
          Copies a file to folder with specified copy params and returns copied destination.
static java.io.File copyFileToDir(java.lang.String src, java.lang.String destDir)
           
static java.io.File copyFileToDir(java.lang.String src, java.lang.String destDir, FileUtilParams params)
           
static java.io.File createTempDirectory(java.lang.String prefix, java.lang.String suffix)
           
static java.io.File createTempDirectory(java.lang.String prefix, java.lang.String suffix, java.io.File tempDir)
          Creates temporary directory.
static java.io.File createTempDirectory(java.lang.String prefix, java.lang.String suffix, java.lang.String tempDirName)
           
static java.io.File createTempFile()
           
static java.io.File createTempFile(boolean create)
           
static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix)
           
static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, boolean create)
           
static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, java.io.File tempDir)
           
static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, java.io.File tempDir, boolean create)
          Creates temporary file.
static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, java.lang.String tempDirName)
           
static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, java.lang.String tempDirName, boolean create)
           
static void delete(java.io.File dest)
           
static void delete(java.io.File dest, FileUtilParams params)
          Smart delete of destination file or directory.
static void delete(java.lang.String dest)
           
static void delete(java.lang.String dest, FileUtilParams params)
           
static void deleteDir(java.io.File dest)
           
static void deleteDir(java.io.File dest, FileUtilParams params)
          Deletes a directory.
static void deleteDir(java.lang.String dest)
           
static void deleteDir(java.lang.String dest, FileUtilParams params)
           
static void deleteFile(java.io.File dest)
           
static void deleteFile(java.lang.String dest)
           
protected static void doCopy(java.io.File src, java.io.File dest)
          Copies one file to another without any checking.
protected static void doCopy(java.lang.String src, java.lang.String dest)
          Copies one file to another without any checking.
static boolean equals(java.io.File file1, java.io.File file2)
          Checks if two files points to the same file.
static boolean equals(java.lang.String file1, java.lang.String file2)
          Checks if two files points to the same file.
static java.io.File getParentFile(java.io.File file)
          Returns parent for the file.
static boolean isAncestor(java.io.File ancestor, java.io.File file, boolean strict)
          Check if one file is an ancestor of second one.
static boolean isFilePathAcceptable(java.io.File file, java.io.FileFilter fileFilter)
           
static boolean isNewer(java.io.File file, java.io.File reference)
          Test if specified File is newer than the reference File.
static boolean isNewer(java.io.File file, long timeMillis)
          Tests if the specified File is newer than the specified time reference.
static boolean isNewer(java.lang.String file, long timeMillis)
           
static boolean isNewer(java.lang.String file, java.lang.String reference)
           
static boolean isOlder(java.io.File file, java.io.File reference)
           
static boolean isOlder(java.io.File file, long timeMillis)
           
static boolean isOlder(java.lang.String file, long timeMillis)
           
static boolean isOlder(java.lang.String file, java.lang.String reference)
           
static void mkdir(java.io.File dir)
          Creates single folders.
static void mkdir(java.lang.String dir)
          Creates single folder.
static void mkdirs(java.io.File dirs)
          Creates all folders at once.
static void mkdirs(java.lang.String dirs)
          Creates all folders at once.
static void move(java.io.File src, java.io.File dest)
           
static void move(java.io.File src, java.io.File dest, FileUtilParams params)
          Smart move.
static void move(java.lang.String src, java.lang.String dest)
           
static void move(java.lang.String src, java.lang.String dest, FileUtilParams params)
           
static void moveDir(java.io.File srcDir, java.io.File destDir)
           
static void moveDir(java.lang.String srcDir, java.lang.String destDir)
           
static void moveFile(java.io.File src, java.io.File dest)
           
static void moveFile(java.io.File src, java.io.File dest, FileUtilParams params)
           
static void moveFile(java.lang.String src, java.lang.String dest)
           
static void moveFile(java.lang.String src, java.lang.String dest, FileUtilParams params)
           
static void moveFileToDir(java.io.File src, java.io.File destDir)
           
static void moveFileToDir(java.io.File src, java.io.File destDir, FileUtilParams params)
           
static void moveFileToDir(java.lang.String src, java.lang.String destDir)
           
static void moveFileToDir(java.lang.String src, java.lang.String destDir, FileUtilParams params)
           
protected static void outBytes(java.io.File dest, byte[] data, int off, int len, boolean append)
           
protected static void outChars(java.io.File dest, char[] data, java.lang.String encoding, boolean append)
           
protected static void outString(java.io.File dest, java.lang.String data, java.lang.String encoding, boolean append)
           
static FileUtilParams params()
          Creates new FileUtilParams instance with default values.
static byte[] readBytes(java.io.File file)
           
static byte[] readBytes(java.lang.String file)
           
static char[] readChars(java.io.File file)
           
static char[] readChars(java.io.File file, java.lang.String encoding)
          Reads file content as char array.
static char[] readChars(java.lang.String fileName)
           
static char[] readChars(java.lang.String fileName, java.lang.String encoding)
           
static java.lang.String[] readLines(java.io.File source)
           
static java.lang.String[] readLines(java.io.File file, java.lang.String encoding)
          Reads lines from source files.
static java.lang.String[] readLines(java.lang.String source)
           
static java.lang.String[] readLines(java.lang.String source, java.lang.String encoding)
           
static java.lang.String readString(java.io.File source)
           
static java.lang.String readString(java.io.File file, java.lang.String encoding)
          Reads file content as string.
static java.lang.String readString(java.lang.String source)
           
static java.lang.String readString(java.lang.String source, java.lang.String encoding)
           
static java.io.File toFile(java.net.URI uri)
          Converts URI to file.
static java.io.File toFile(java.net.URL url)
          Converts file URLs to file.
static java.lang.String toFileName(java.net.URL url)
          Converts file URLs to file name.
static java.lang.String toFileNames(java.net.URL[] urls)
          Converts array of URLS to file names string.
static void touch(java.io.File file)
          Implements the Unix "touch" utility.
static void touch(java.lang.String file)
          touch(java.io.File)
static void writeBytes(java.io.File dest, byte[] data)
           
static void writeBytes(java.io.File dest, byte[] data, int off, int len)
           
static void writeBytes(java.lang.String dest, byte[] data)
           
static void writeBytes(java.lang.String dest, byte[] data, int off, int len)
           
static void writeChars(java.io.File dest, char[] data)
           
static void writeChars(java.io.File dest, char[] data, java.lang.String encoding)
           
static void writeChars(java.lang.String dest, char[] data)
           
static void writeChars(java.lang.String dest, char[] data, java.lang.String encoding)
           
static void writeStream(java.io.File dest, java.io.InputStream in)
           
static void writeStream(java.lang.String dest, java.io.InputStream in)
           
static void writeString(java.io.File dest, java.lang.String data)
           
static void writeString(java.io.File dest, java.lang.String data, java.lang.String encoding)
           
static void writeString(java.lang.String dest, java.lang.String data)
           
static void writeString(java.lang.String dest, java.lang.String data, java.lang.String encoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultParams

public static FileUtilParams defaultParams
Constructor Detail

FileUtil

public FileUtil()
Method Detail

equals

public static boolean equals(java.lang.String file1,
                             java.lang.String file2)
Checks if two files points to the same file.


equals

public static boolean equals(java.io.File file1,
                             java.io.File file2)
Checks if two files points to the same file.


toFile

public static java.io.File toFile(java.net.URI uri)
Converts URI to file. Returns null in case of invalid URI.


toFile

public static java.io.File toFile(java.net.URL url)
Converts file URLs to file. Ignores other schemes and returns null.


toFileName

public static java.lang.String toFileName(java.net.URL url)
Converts file URLs to file name. Ignores other schemes and returns null.


toFileNames

public static java.lang.String toFileNames(java.net.URL[] urls)
Converts array of URLS to file names string. Other schemes are ignored.


mkdirs

public static void mkdirs(java.lang.String dirs)
                   throws java.io.IOException
Creates all folders at once.

Throws:
java.io.IOException

mkdirs

public static void mkdirs(java.io.File dirs)
                   throws java.io.IOException
Creates all folders at once.

Throws:
java.io.IOException

mkdir

public static void mkdir(java.lang.String dir)
                  throws java.io.IOException
Creates single folder.

Throws:
java.io.IOException

mkdir

public static void mkdir(java.io.File dir)
                  throws java.io.IOException
Creates single folders.

Throws:
java.io.IOException

touch

public static void touch(java.lang.String file)
                  throws java.io.IOException
touch(java.io.File)

Throws:
java.io.IOException

touch

public static void touch(java.io.File file)
                  throws java.io.IOException
Implements the Unix "touch" utility. It creates a new file with size 0 or, if the file exists already, it is opened and closed without modifying it, but updating the file date and time.

Throws:
java.io.IOException

cloneParams

public static FileUtilParams cloneParams()
Creates new FileUtilParams instance by cloning current default params.


params

public static FileUtilParams params()
Creates new FileUtilParams instance with default values.


copyFile

public static void copyFile(java.lang.String src,
                            java.lang.String dest)
                     throws java.io.IOException
Throws:
java.io.IOException

copyFile

public static void copyFile(java.lang.String src,
                            java.lang.String dest,
                            FileUtilParams params)
                     throws java.io.IOException
Throws:
java.io.IOException

copyFile

public static void copyFile(java.io.File src,
                            java.io.File dest)
                     throws java.io.IOException
Throws:
java.io.IOException

copyFile

public static void copyFile(java.io.File src,
                            java.io.File dest,
                            FileUtilParams params)
                     throws java.io.IOException
Copies a file to another file with specified copy params.

Throws:
java.io.IOException

doCopy

protected static void doCopy(java.lang.String src,
                             java.lang.String dest)
                      throws java.io.IOException
Copies one file to another without any checking.

Throws:
java.io.IOException
See Also:
doCopy(java.io.File, java.io.File)

doCopy

protected static void doCopy(java.io.File src,
                             java.io.File dest)
                      throws java.io.IOException
Copies one file to another without any checking. It is assumed that both parameters represents valid files.

Throws:
java.io.IOException

copyFileToDir

public static java.io.File copyFileToDir(java.lang.String src,
                                         java.lang.String destDir)
                                  throws java.io.IOException
Throws:
java.io.IOException
See Also:
copyFileToDir(java.io.File, java.io.File, FileUtilParams)

copyFileToDir

public static java.io.File copyFileToDir(java.lang.String src,
                                         java.lang.String destDir,
                                         FileUtilParams params)
                                  throws java.io.IOException
Throws:
java.io.IOException
See Also:
copyFileToDir(java.io.File, java.io.File, FileUtilParams)

copyFileToDir

public static java.io.File copyFileToDir(java.io.File src,
                                         java.io.File destDir)
                                  throws java.io.IOException
Throws:
java.io.IOException
See Also:
copyFileToDir(java.io.File, java.io.File, FileUtilParams)

copyFileToDir

public static java.io.File copyFileToDir(java.io.File src,
                                         java.io.File destDir,
                                         FileUtilParams params)
                                  throws java.io.IOException
Copies a file to folder with specified copy params and returns copied destination.

Throws:
java.io.IOException

copyDir

public static void copyDir(java.lang.String srcDir,
                           java.lang.String destDir)
                    throws java.io.IOException
Throws:
java.io.IOException

copyDir

public static void copyDir(java.lang.String srcDir,
                           java.lang.String destDir,
                           FileUtilParams params)
                    throws java.io.IOException
Throws:
java.io.IOException

copyDir

public static void copyDir(java.io.File srcDir,
                           java.io.File destDir)
                    throws java.io.IOException
Throws:
java.io.IOException

copyDir

public static void copyDir(java.io.File srcDir,
                           java.io.File destDir,
                           FileUtilParams params)
                    throws java.io.IOException
Copies directory with specified copy params.

Throws:
java.io.IOException

moveFile

public static void moveFile(java.lang.String src,
                            java.lang.String dest)
                     throws java.io.IOException
Throws:
java.io.IOException

moveFile

public static void moveFile(java.lang.String src,
                            java.lang.String dest,
                            FileUtilParams params)
                     throws java.io.IOException
Throws:
java.io.IOException

moveFile

public static void moveFile(java.io.File src,
                            java.io.File dest)
                     throws java.io.IOException
Throws:
java.io.IOException

moveFile

public static void moveFile(java.io.File src,
                            java.io.File dest,
                            FileUtilParams params)
                     throws java.io.IOException
Throws:
java.io.IOException

moveFileToDir

public static void moveFileToDir(java.lang.String src,
                                 java.lang.String destDir)
                          throws java.io.IOException
Throws:
java.io.IOException

moveFileToDir

public static void moveFileToDir(java.lang.String src,
                                 java.lang.String destDir,
                                 FileUtilParams params)
                          throws java.io.IOException
Throws:
java.io.IOException

moveFileToDir

public static void moveFileToDir(java.io.File src,
                                 java.io.File destDir)
                          throws java.io.IOException
Throws:
java.io.IOException

moveFileToDir

public static void moveFileToDir(java.io.File src,
                                 java.io.File destDir,
                                 FileUtilParams params)
                          throws java.io.IOException
Throws:
java.io.IOException

moveDir

public static void moveDir(java.lang.String srcDir,
                           java.lang.String destDir)
                    throws java.io.IOException
Throws:
java.io.IOException

moveDir

public static void moveDir(java.io.File srcDir,
                           java.io.File destDir)
                    throws java.io.IOException
Throws:
java.io.IOException

deleteFile

public static void deleteFile(java.lang.String dest)
                       throws java.io.IOException
Throws:
java.io.IOException

deleteFile

public static void deleteFile(java.io.File dest)
                       throws java.io.IOException
Throws:
java.io.IOException

deleteDir

public static void deleteDir(java.lang.String dest)
                      throws java.io.IOException
Throws:
java.io.IOException

deleteDir

public static void deleteDir(java.lang.String dest,
                             FileUtilParams params)
                      throws java.io.IOException
Throws:
java.io.IOException

deleteDir

public static void deleteDir(java.io.File dest)
                      throws java.io.IOException
Throws:
java.io.IOException

deleteDir

public static void deleteDir(java.io.File dest,
                             FileUtilParams params)
                      throws java.io.IOException
Deletes a directory.

Throws:
java.io.IOException

cleanDir

public static void cleanDir(java.lang.String dest)
                     throws java.io.IOException
Throws:
java.io.IOException

cleanDir

public static void cleanDir(java.lang.String dest,
                            FileUtilParams params)
                     throws java.io.IOException
Throws:
java.io.IOException

cleanDir

public static void cleanDir(java.io.File dest)
                     throws java.io.IOException
Throws:
java.io.IOException

cleanDir

public static void cleanDir(java.io.File dest,
                            FileUtilParams params)
                     throws java.io.IOException
Cleans a directory without deleting it.

Throws:
java.io.IOException

readChars

public static char[] readChars(java.lang.String fileName)
                        throws java.io.IOException
Throws:
java.io.IOException

readChars

public static char[] readChars(java.io.File file)
                        throws java.io.IOException
Throws:
java.io.IOException

readChars

public static char[] readChars(java.lang.String fileName,
                               java.lang.String encoding)
                        throws java.io.IOException
Throws:
java.io.IOException

readChars

public static char[] readChars(java.io.File file,
                               java.lang.String encoding)
                        throws java.io.IOException
Reads file content as char array.

Throws:
java.io.IOException

writeChars

public static void writeChars(java.io.File dest,
                              char[] data)
                       throws java.io.IOException
Throws:
java.io.IOException

writeChars

public static void writeChars(java.lang.String dest,
                              char[] data)
                       throws java.io.IOException
Throws:
java.io.IOException

writeChars

public static void writeChars(java.io.File dest,
                              char[] data,
                              java.lang.String encoding)
                       throws java.io.IOException
Throws:
java.io.IOException

writeChars

public static void writeChars(java.lang.String dest,
                              char[] data,
                              java.lang.String encoding)
                       throws java.io.IOException
Throws:
java.io.IOException

outChars

protected static void outChars(java.io.File dest,
                               char[] data,
                               java.lang.String encoding,
                               boolean append)
                        throws java.io.IOException
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.lang.String source)
                                   throws java.io.IOException
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.lang.String source,
                                          java.lang.String encoding)
                                   throws java.io.IOException
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.io.File source)
                                   throws java.io.IOException
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.io.File file,
                                          java.lang.String encoding)
                                   throws java.io.IOException
Reads file content as string.

Throws:
java.io.IOException

writeString

public static void writeString(java.lang.String dest,
                               java.lang.String data)
                        throws java.io.IOException
Throws:
java.io.IOException

writeString

public static void writeString(java.lang.String dest,
                               java.lang.String data,
                               java.lang.String encoding)
                        throws java.io.IOException
Throws:
java.io.IOException

writeString

public static void writeString(java.io.File dest,
                               java.lang.String data)
                        throws java.io.IOException
Throws:
java.io.IOException

writeString

public static void writeString(java.io.File dest,
                               java.lang.String data,
                               java.lang.String encoding)
                        throws java.io.IOException
Throws:
java.io.IOException

appendString

public static void appendString(java.lang.String dest,
                                java.lang.String data)
                         throws java.io.IOException
Throws:
java.io.IOException

appendString

public static void appendString(java.lang.String dest,
                                java.lang.String data,
                                java.lang.String encoding)
                         throws java.io.IOException
Throws:
java.io.IOException

appendString

public static void appendString(java.io.File dest,
                                java.lang.String data)
                         throws java.io.IOException
Throws:
java.io.IOException

appendString

public static void appendString(java.io.File dest,
                                java.lang.String data,
                                java.lang.String encoding)
                         throws java.io.IOException
Throws:
java.io.IOException

outString

protected static void outString(java.io.File dest,
                                java.lang.String data,
                                java.lang.String encoding,
                                boolean append)
                         throws java.io.IOException
Throws:
java.io.IOException

writeStream

public static void writeStream(java.io.File dest,
                               java.io.InputStream in)
                        throws java.io.IOException
Throws:
java.io.IOException

writeStream

public static void writeStream(java.lang.String dest,
                               java.io.InputStream in)
                        throws java.io.IOException
Throws:
java.io.IOException

readLines

public static java.lang.String[] readLines(java.lang.String source)
                                    throws java.io.IOException
Throws:
java.io.IOException

readLines

public static java.lang.String[] readLines(java.lang.String source,
                                           java.lang.String encoding)
                                    throws java.io.IOException
Throws:
java.io.IOException

readLines

public static java.lang.String[] readLines(java.io.File source)
                                    throws java.io.IOException
Throws:
java.io.IOException

readLines

public static java.lang.String[] readLines(java.io.File file,
                                           java.lang.String encoding)
                                    throws java.io.IOException
Reads lines from source files.

Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.lang.String file)
                        throws java.io.IOException
Throws:
java.io.IOException

readBytes

public static byte[] readBytes(java.io.File file)
                        throws java.io.IOException
Throws:
java.io.IOException

writeBytes

public static void writeBytes(java.lang.String dest,
                              byte[] data)
                       throws java.io.IOException
Throws:
java.io.IOException

writeBytes

public static void writeBytes(java.lang.String dest,
                              byte[] data,
                              int off,
                              int len)
                       throws java.io.IOException
Throws:
java.io.IOException

writeBytes

public static void writeBytes(java.io.File dest,
                              byte[] data)
                       throws java.io.IOException
Throws:
java.io.IOException

writeBytes

public static void writeBytes(java.io.File dest,
                              byte[] data,
                              int off,
                              int len)
                       throws java.io.IOException
Throws:
java.io.IOException

appendBytes

public static void appendBytes(java.lang.String dest,
                               byte[] data)
                        throws java.io.IOException
Throws:
java.io.IOException

appendBytes

public static void appendBytes(java.lang.String dest,
                               byte[] data,
                               int off,
                               int len)
                        throws java.io.IOException
Throws:
java.io.IOException

appendBytes

public static void appendBytes(java.io.File dest,
                               byte[] data)
                        throws java.io.IOException
Throws:
java.io.IOException

appendBytes

public static void appendBytes(java.io.File dest,
                               byte[] data,
                               int off,
                               int len)
                        throws java.io.IOException
Throws:
java.io.IOException

outBytes

protected static void outBytes(java.io.File dest,
                               byte[] data,
                               int off,
                               int len,
                               boolean append)
                        throws java.io.IOException
Throws:
java.io.IOException

compare

public static boolean compare(java.lang.String file1,
                              java.lang.String file2)
                       throws java.io.IOException
Throws:
java.io.IOException

compare

public static boolean compare(java.io.File file1,
                              java.io.File file2)
                       throws java.io.IOException
Compare the contents of two files to determine if they are equal or not.

This method checks to see if the two files are different lengths or if they point to the same file, before resorting to byte-by-byte comparison of the contents.

Code origin: Avalon

Throws:
java.io.IOException

isNewer

public static boolean isNewer(java.lang.String file,
                              java.lang.String reference)

isNewer

public static boolean isNewer(java.io.File file,
                              java.io.File reference)
Test if specified File is newer than the reference File.

Parameters:
file - the File of which the modification date must be compared
reference - the File of which the modification date is used
Returns:
true if the File exists and has been modified more recently than the reference File.

isOlder

public static boolean isOlder(java.lang.String file,
                              java.lang.String reference)

isOlder

public static boolean isOlder(java.io.File file,
                              java.io.File reference)

isNewer

public static boolean isNewer(java.io.File file,
                              long timeMillis)
Tests if the specified File is newer than the specified time reference.

Parameters:
file - the File of which the modification date must be compared.
timeMillis - the time reference measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)
Returns:
true if the File exists and has been modified after the given time reference.

isNewer

public static boolean isNewer(java.lang.String file,
                              long timeMillis)

isOlder

public static boolean isOlder(java.io.File file,
                              long timeMillis)

isOlder

public static boolean isOlder(java.lang.String file,
                              long timeMillis)

copy

public static void copy(java.lang.String src,
                        java.lang.String dest)
                 throws java.io.IOException
Throws:
java.io.IOException

copy

public static void copy(java.lang.String src,
                        java.lang.String dest,
                        FileUtilParams params)
                 throws java.io.IOException
Throws:
java.io.IOException

copy

public static void copy(java.io.File src,
                        java.io.File dest)
                 throws java.io.IOException
Throws:
java.io.IOException

copy

public static void copy(java.io.File src,
                        java.io.File dest,
                        FileUtilParams params)
                 throws java.io.IOException
Smart copy. If source is a directory, copy it to destination. Otherwise, if destination is directory, copy source file to it. Otherwise, try to copy source file to destination file.

Throws:
java.io.IOException

move

public static void move(java.lang.String src,
                        java.lang.String dest)
                 throws java.io.IOException
Throws:
java.io.IOException

move

public static void move(java.lang.String src,
                        java.lang.String dest,
                        FileUtilParams params)
                 throws java.io.IOException
Throws:
java.io.IOException

move

public static void move(java.io.File src,
                        java.io.File dest)
                 throws java.io.IOException
Throws:
java.io.IOException

move

public static void move(java.io.File src,
                        java.io.File dest,
                        FileUtilParams params)
                 throws java.io.IOException
Smart move. If source is a directory, move it to destination. Otherwise, if destination is directory, move source file to it. Otherwise, try to move source file to destination file.

Throws:
java.io.IOException

delete

public static void delete(java.lang.String dest)
                   throws java.io.IOException
Throws:
java.io.IOException

delete

public static void delete(java.lang.String dest,
                          FileUtilParams params)
                   throws java.io.IOException
Throws:
java.io.IOException

delete

public static void delete(java.io.File dest)
                   throws java.io.IOException
Throws:
java.io.IOException

delete

public static void delete(java.io.File dest,
                          FileUtilParams params)
                   throws java.io.IOException
Smart delete of destination file or directory.

Throws:
java.io.IOException

isAncestor

public static boolean isAncestor(java.io.File ancestor,
                                 java.io.File file,
                                 boolean strict)
Check if one file is an ancestor of second one.

Parameters:
strict - if false then this method returns true if ancestor and file are equal
Returns:
true if ancestor is parent of file; false otherwise

getParentFile

public static java.io.File getParentFile(java.io.File file)
Returns parent for the file. The method correctly processes "." and ".." in file names. The name remains relative if was relative before. Returns null if the file has no parent.


isFilePathAcceptable

public static boolean isFilePathAcceptable(java.io.File file,
                                           java.io.FileFilter fileFilter)

createTempDirectory

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

createTempDirectory

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

createTempDirectory

public static java.io.File createTempDirectory(java.lang.String prefix,
                                               java.lang.String suffix,
                                               java.io.File tempDir)
                                        throws java.io.IOException
Creates temporary directory.

Throws:
java.io.IOException

createTempFile

public static java.io.File createTempFile()
                                   throws java.io.IOException
Throws:
java.io.IOException

createTempFile

public static java.io.File createTempFile(boolean create)
                                   throws java.io.IOException
Throws:
java.io.IOException

createTempFile

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

createTempFile

public static java.io.File createTempFile(java.lang.String prefix,
                                          java.lang.String suffix,
                                          boolean create)
                                   throws java.io.IOException
Throws:
java.io.IOException

createTempFile

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

createTempFile

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

createTempFile

public static java.io.File createTempFile(java.lang.String prefix,
                                          java.lang.String suffix,
                                          java.lang.String tempDirName,
                                          boolean create)
                                   throws java.io.IOException
Throws:
java.io.IOException

createTempFile

public static java.io.File createTempFile(java.lang.String prefix,
                                          java.lang.String suffix,
                                          java.io.File tempDir,
                                          boolean create)
                                   throws java.io.IOException
Creates temporary file. If create is set to true file will be physically created on the file system. Otherwise, it will be created and then deleted - trick that will make temp file exist only if they are used.

Throws:
java.io.IOException


Copyright © 2003-2012 Jodd Team