public class FileUtil
extends java.lang.Object
| Constructor and Description |
|---|
FileUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendBytes(java.io.File dest,
byte[] data) |
static void |
appendBytes(java.io.File dest,
byte[] data,
int off,
int len)
Appends bytes. append = true
|
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)
Appends String. append = true
|
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 destDir)
Cleans a directory without deleting it.
|
static void |
cleanDir(java.lang.String dest) |
static boolean |
compare(java.io.File one,
java.io.File two)
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)
Smart copy.
|
static void |
copy(java.lang.String src,
java.lang.String dest) |
static void |
copyDir(java.io.File srcDir,
java.io.File destDir)
Copies directory with specified copy params.
|
static void |
copyDir(java.lang.String srcDir,
java.lang.String destDir) |
static void |
copyFile(java.io.File srcFile,
java.io.File destFile)
Copies a
File to another File. |
static void |
copyFile(java.lang.String srcFile,
java.lang.String destFile) |
static java.io.File |
copyFileToDir(java.io.File srcFile,
java.io.File destDir)
Copies a
File to directory with specified copy params and returns copied destination. |
static java.io.File |
copyFileToDir(java.lang.String srcFile,
java.lang.String destDir) |
static java.io.File |
createTempDirectory() |
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 |
createTempFile() |
static java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix,
java.io.File tempDir)
Creates temporary
File. |
static java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix,
java.io.File tempDir,
boolean create)
Creates temporary
File. |
static void |
delete(java.io.File dest)
Smart delete of destination file or directory.
|
static void |
delete(java.lang.String dest) |
static void |
deleteDir(java.io.File destDir)
Deletes a directory.
|
static void |
deleteDir(java.lang.String destDir) |
static void |
deleteFile(java.io.File destFile)
Deletes a
File. |
static void |
deleteFile(java.lang.String destFile) |
static boolean |
equals(java.io.File one,
java.io.File two)
Checks if two
Files point to the same File. |
static boolean |
equals(java.lang.String one,
java.lang.String two) |
static java.io.File |
file(java.lang.String fileName)
Simple factory for
File objects but with home resolving. |
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 |
isBinary(java.io.File file)
Checks the start of the file for ASCII control characters
|
static boolean |
isExistingFile(java.io.File file)
Returns
true if File exists. |
static boolean |
isExistingFolder(java.io.File folder)
Returns
true if directory exists. |
static boolean |
isFilePathAcceptable(java.io.File file,
java.io.FileFilter fileFilter)
Checks if file and its ancestors are acceptable by using
FileFilter.accept(File). |
static boolean |
isNewer(java.io.File file,
java.io.File reference)
Uses
File.lastModified() for reference. |
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)
Uses
File.lastModified() for reference. |
static boolean |
isOlder(java.io.File file,
long timeMillis)
Tests if the specified
File is older than the specified time reference. |
static boolean |
isOlder(java.lang.String file,
long timeMillis) |
static boolean |
isOlder(java.lang.String file,
java.lang.String reference) |
static boolean |
isSymlink(java.io.File file)
Deprecated.
Files.isSymbolicLink(java.nio.file.Path) provides this functionality natively as of Java 1.7. |
static java.lang.String |
md5(java.io.File file)
Creates MD5 digest of a
File. |
static java.io.File |
mkdir(java.io.File dir)
Creates single directory.
|
static java.io.File |
mkdir(java.lang.String dir) |
static java.io.File |
mkdirs(java.io.File dirs)
Creates all directories at once.
|
static java.io.File |
mkdirs(java.lang.String dirs) |
static void |
move(java.io.File src,
java.io.File dest)
Smart move.
|
static void |
move(java.lang.String src,
java.lang.String dest) |
static java.io.File |
moveDir(java.io.File srcDir,
java.io.File destDir) |
static java.io.File |
moveDir(java.lang.String srcDir,
java.lang.String destDir) |
static java.io.File |
moveFile(java.io.File srcFile,
java.io.File destFile) |
static java.io.File |
moveFile(java.lang.String srcFile,
java.lang.String destFile) |
static java.io.File |
moveFileToDir(java.io.File srcFile,
java.io.File destDir)
Moves a file to a directory.
|
static java.io.File |
moveFileToDir(java.lang.String srcFile,
java.lang.String destDir) |
protected static void |
outBytes(java.io.File dest,
byte[] data,
int off,
int len,
boolean append)
Writes data to
File destination. |
protected static void |
outChars(java.io.File dest,
char[] data,
java.lang.String encoding,
boolean append)
Writes characters to
File destination. |
protected static void |
outString(java.io.File dest,
java.lang.String data,
java.lang.String encoding,
boolean append)
Writes data using encoding to
File. |
static byte[] |
readBytes(java.io.File file) |
static byte[] |
readBytes(java.io.File file,
int count)
Read file and returns byte array with contents.
|
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
File with specified encoding and returns lines as Strings in array. |
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 encoded in provided encoding. |
static java.lang.String |
readString(java.lang.String source) |
static java.lang.String |
readString(java.lang.String source,
java.lang.String encoding) |
static char[] |
readUTFChars(java.io.File file)
Reads UTF file content as char array.
|
static char[] |
readUTFChars(java.lang.String fileName) |
static java.lang.String |
readUTFString(java.io.File file)
Detects optional BOM and reads UTF
String from a File. |
static java.lang.String |
readUTFString(java.io.InputStream inputStream)
Detects optional BOM and reads UTF
String from an InputStream. |
static java.lang.String |
readUTFString(java.lang.String fileName) |
static java.lang.String |
sha256(java.io.File file)
Creates SHA-256 digest of a file.
|
static java.lang.String |
sha512(java.io.File file)
Creates SHA-512 digest of a file.
|
static java.io.File |
toContainerFile(java.net.URL url)
Returns a file of either a folder or a containing archive.
|
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 void |
touch(java.io.File file)
Implements the Unix "touch" utility.
|
static void |
touch(java.lang.String file) |
static java.net.URL |
toURL(java.io.File file)
Converts
File to URL in a correct way. |
static void |
writeBytes(java.io.File dest,
byte[] data) |
static void |
writeBytes(java.io.File dest,
byte[] data,
int off,
int len)
Write bytes. append = false
|
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)
Write characters. append = false
|
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.io.FileOutputStream out,
java.io.InputStream in)
Write
InputStream in to FileOutputStream. |
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)
Writes String. append = false
|
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) |
public static java.io.File file(java.lang.String fileName)
File objects but with home resolving.public static boolean equals(java.lang.String one,
java.lang.String two)
equals(File, File)public static boolean equals(java.io.File one,
java.io.File two)
Files point to the same File.one - File one.two - File two.true if the Files match.public static java.io.File toFile(java.net.URL url)
File URLs to File. Ignores other schemes and returns null.public static java.net.URL toURL(java.io.File file)
throws java.net.MalformedURLException
File to URL in a correct way.URL or null in case of error.java.net.MalformedURLException - if File cannot be converted.public static java.lang.String toFileName(java.net.URL url)
File URLs to file name. Accepts only URLs with 'file' protocol.
Otherwise, for other schemes returns null.url - URL to convertpublic static java.io.File toContainerFile(java.net.URL url)
public static boolean isExistingFile(java.io.File file)
true if File exists.public static boolean isExistingFolder(java.io.File folder)
true if directory exists.public static java.io.File mkdirs(java.lang.String dirs)
throws java.io.IOException
java.io.IOExceptionmkdirs(File)public static java.io.File mkdirs(java.io.File dirs)
throws java.io.IOException
dirs - Directories to make.java.io.IOException - if cannot create directory.public static java.io.File mkdir(java.lang.String dir)
throws java.io.IOException
java.io.IOExceptionmkdir(File)public static java.io.File mkdir(java.io.File dir)
throws java.io.IOException
java.io.IOException - if cannot create directory.public static void touch(java.lang.String file)
throws java.io.IOException
java.io.IOExceptiontouch(File)public static void touch(java.io.File file)
throws java.io.IOException
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.java.io.IOExceptionpublic static void copyFile(java.lang.String srcFile,
java.lang.String destFile)
throws java.io.IOException
java.io.IOExceptioncopyFile(File, File)public static void copyFile(java.io.File srcFile,
java.io.File destFile)
throws java.io.IOException
File to another File.srcFile - Source File.destFile - Destination File.java.io.IOException - if cannot copypublic static java.io.File copyFileToDir(java.lang.String srcFile,
java.lang.String destDir)
throws java.io.IOException
java.io.IOExceptioncopyFileToDir(File, File)public static java.io.File copyFileToDir(java.io.File srcFile,
java.io.File destDir)
throws java.io.IOException
File to directory with specified copy params and returns copied destination.java.io.IOExceptionpublic static void copyDir(java.lang.String srcDir,
java.lang.String destDir)
throws java.io.IOException
java.io.IOExceptioncopyDir(File, File)public static void copyDir(java.io.File srcDir,
java.io.File destDir)
throws java.io.IOException
java.io.IOException_copyDirectory(File, File)public static java.io.File moveFile(java.lang.String srcFile,
java.lang.String destFile)
throws java.io.IOException
java.io.IOExceptionmoveFile(File, File)public static java.io.File moveFile(java.io.File srcFile,
java.io.File destFile)
throws java.io.IOException
java.io.IOException_moveFile(File, File)public static java.io.File moveFileToDir(java.lang.String srcFile,
java.lang.String destDir)
throws java.io.IOException
java.io.IOExceptionmoveFileToDir(File, File)public static java.io.File moveFileToDir(java.io.File srcFile,
java.io.File destDir)
throws java.io.IOException
srcFile - Source File.destDir - Destination directory.java.io.IOException - if there is an error during move.public static java.io.File moveDir(java.lang.String srcDir,
java.lang.String destDir)
throws java.io.IOException
java.io.IOExceptionmoveDir(File, File)public static java.io.File moveDir(java.io.File srcDir,
java.io.File destDir)
throws java.io.IOException
java.io.IOException_moveDirectory(File, File)public static void deleteFile(java.lang.String destFile)
throws java.io.IOException
java.io.IOExceptiondeleteFile(File)public static void deleteFile(java.io.File destFile)
throws java.io.IOException
File.destFile - Destination to delete.java.io.IOException - if there was an error deleting.public static void deleteDir(java.lang.String destDir)
throws java.io.IOException
java.io.IOExceptiondeleteDir(File)public static void deleteDir(java.io.File destDir)
throws java.io.IOException
destDir - Destination to delete.java.io.IOException - if there was an error deleting.public static void cleanDir(java.lang.String dest)
throws java.io.IOException
java.io.IOExceptioncleanDir(File)public static void cleanDir(java.io.File destDir)
throws java.io.IOException
destDir - destination to clean.java.io.IOException - if something went wrong.public static char[] readUTFChars(java.lang.String fileName)
throws java.io.IOException
java.io.IOExceptionreadUTFChars(File)public static char[] readUTFChars(java.io.File file)
throws java.io.IOException
file - File to read.java.io.IOException - if something went wrong.public static char[] readChars(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
file - File to read.encoding - Encoding to use.java.io.IOException - if something went wrong.public static char[] readChars(java.lang.String fileName)
throws java.io.IOException
java.io.IOExceptionreadChars(String, String)public static char[] readChars(java.io.File file)
throws java.io.IOException
java.io.IOExceptionreadChars(File, String)public static char[] readChars(java.lang.String fileName,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionreadChars(File, String)public static void writeChars(java.io.File dest,
char[] data)
throws java.io.IOException
java.io.IOExceptionwriteChars(File, char[], String)public static void writeChars(java.lang.String dest,
char[] data)
throws java.io.IOException
java.io.IOExceptionwriteChars(File, char[])public static void writeChars(java.lang.String dest,
char[] data,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionwriteChars(File, char[], String)public static void writeChars(java.io.File dest,
char[] data,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionoutChars(File, char[], String, boolean)protected static void outChars(java.io.File dest,
char[] data,
java.lang.String encoding,
boolean append)
throws java.io.IOException
File destination.dest - destination Filedata - Data as a Stringencoding - Encoding as a Stringappend - true if appending; false if File should be overwritten.java.io.IOException - if something went wrong.public static java.lang.String readUTFString(java.lang.String fileName)
throws java.io.IOException
java.io.IOExceptionreadUTFString(File)public static java.lang.String readUTFString(java.io.File file)
throws java.io.IOException
String from a File.
If BOM is missing, UTF-8 is assumed.file - File to read.java.io.IOException - if copy to InputStream errors.unicodeInputStreamOf(File),
StreamUtil.copy(InputStream, String)public static java.lang.String readUTFString(java.io.InputStream inputStream)
throws java.io.IOException
String from an InputStream.
If BOM is missing, UTF-8 is assumed.inputStream - InputStream to read.java.io.IOException - if copy to InputStream errors.unicodeInputStreamOf(File),
StreamUtil.copy(InputStream, String)public static java.lang.String readString(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
File content as String encoded in provided encoding.
For UTF encoded files, detects optional BOM characters.file - File to read.encoding - Encoding to use.File content.java.io.IOException - if copy to InputStream errors.streamOf(File, String),
StreamUtil.copy(InputStream, String)public static java.lang.String readString(java.lang.String source)
throws java.io.IOException
java.io.IOExceptionreadString(String, String)public static java.lang.String readString(java.lang.String source,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionreadString(File, String)public static java.lang.String readString(java.io.File source)
throws java.io.IOException
java.io.IOExceptionreadString(File, String)public static void writeString(java.lang.String dest,
java.lang.String data)
throws java.io.IOException
java.io.IOExceptionwriteString(File, String, String)public static void writeString(java.lang.String dest,
java.lang.String data,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionwriteString(File, String, String)public static void writeString(java.io.File dest,
java.lang.String data)
throws java.io.IOException
java.io.IOExceptionwriteString(File, String, String)public static void writeString(java.io.File dest,
java.lang.String data,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionoutString(File, String, String, boolean)public static void appendString(java.lang.String dest,
java.lang.String data)
throws java.io.IOException
java.io.IOExceptionappendString(File, String)public static void appendString(java.lang.String dest,
java.lang.String data,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionappendString(File, String, String)public static void appendString(java.io.File dest,
java.lang.String data)
throws java.io.IOException
java.io.IOExceptionappendString(File, String, String)public static void appendString(java.io.File dest,
java.lang.String data,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionoutString(File, String, String, boolean)protected static void outString(java.io.File dest,
java.lang.String data,
java.lang.String encoding,
boolean append)
throws java.io.IOException
File.dest - destination Filedata - Data as a Stringencoding - Encoding as a Stringappend - true if appending; false if File should be overwritten.java.io.IOException - if something went wrong.public static void writeStream(java.lang.String dest,
java.io.InputStream in)
throws java.io.IOException
java.io.IOExceptionwriteStream(File, InputStream)public static void writeStream(java.io.File dest,
java.io.InputStream in)
throws java.io.IOException
java.io.IOExceptionwriteStream(FileOutputStream, InputStream)public static void writeStream(java.io.FileOutputStream out,
java.io.InputStream in)
throws java.io.IOException
InputStream in to FileOutputStream.out - FileOutputStream to write to.in - InputStream to read.java.io.IOException - if there is an issue reading/writing.public static java.lang.String[] readLines(java.lang.String source)
throws java.io.IOException
java.io.IOExceptionreadLines(String, String)public static java.lang.String[] readLines(java.lang.String source,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionreadLines(File, String)public static java.lang.String[] readLines(java.io.File source)
throws java.io.IOException
java.io.IOExceptionreadLines(File, String)public static java.lang.String[] readLines(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
File with specified encoding and returns lines as Strings in array.file - File to read.encoding - Endoing to use.File.java.io.IOException - if File does not exist or is not a File or there is an issue reading
the File.public static byte[] readBytes(java.lang.String file)
throws java.io.IOException
java.io.IOExceptionreadBytes(File)public static byte[] readBytes(java.io.File file)
throws java.io.IOException
java.io.IOExceptionreadBytes(File, int)public static byte[] readBytes(java.io.File file,
int count)
throws java.io.IOException
file - File to readcount - number of bytes to readFile contents.java.io.IOException - if not a File or File does not exist or file size is
larger than Integer.MAX_VALUE.public static void writeBytes(java.lang.String dest,
byte[] data)
throws java.io.IOException
java.io.IOExceptionwriteBytes(File, byte[])public static void writeBytes(java.io.File dest,
byte[] data)
throws java.io.IOException
java.io.IOExceptionwriteBytes(File, byte[], int, int)public static void writeBytes(java.lang.String dest,
byte[] data,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionwriteBytes(File, byte[], int, int)public static void writeBytes(java.io.File dest,
byte[] data,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionoutBytes(File, byte[], int, int, boolean)public static void appendBytes(java.lang.String dest,
byte[] data)
throws java.io.IOException
java.io.IOExceptionappendBytes(File, byte[])public static void appendBytes(java.lang.String dest,
byte[] data,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionappendBytes(File, byte[], int, int)public static void appendBytes(java.io.File dest,
byte[] data)
throws java.io.IOException
java.io.IOExceptionappendBytes(File, byte[], int, int)public static void appendBytes(java.io.File dest,
byte[] data,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionoutBytes(File, byte[], int, int, boolean)protected static void outBytes(java.io.File dest,
byte[] data,
int off,
int len,
boolean append)
throws java.io.IOException
File destination.dest - destination Filedata - Data as a Stringoff - the start offset in the data.len - the number of bytes to write.append - true if appending; false if File should be overwritten.java.io.IOException - if something went wrong.public static boolean compare(java.lang.String file1,
java.lang.String file2)
throws java.io.IOException
java.io.IOExceptionpublic static boolean compare(java.io.File one,
java.io.File two)
throws java.io.IOException
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
java.io.IOExceptionpublic static boolean isOlder(java.lang.String file,
java.lang.String reference)
isOlder(File, File)public static boolean isNewer(java.lang.String file,
java.lang.String reference)
isNewer(File, File)public static boolean isNewer(java.io.File file,
java.io.File reference)
File.lastModified() for reference.isNewer(File, long)public static boolean isOlder(java.io.File file,
java.io.File reference)
File.lastModified() for reference.isOlder(File, long)public static boolean isNewer(java.io.File file,
long timeMillis)
File is newer than the specified time reference.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)true if the File exists and has been modified after
the given time reference.public static boolean isNewer(java.lang.String file,
long timeMillis)
isNewer(File, long)public static boolean isOlder(java.io.File file,
long timeMillis)
File is older than the specified time reference.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)true if the File exists and has been modified after
the given time reference.public static boolean isOlder(java.lang.String file,
long timeMillis)
isOlder(File, long)public static void copy(java.lang.String src,
java.lang.String dest)
throws java.io.IOException
java.io.IOExceptioncopy(File, File)public static void copy(java.io.File src,
java.io.File dest)
throws java.io.IOException
src - source Filedest - destination Filejava.io.IOException - if there is an error copying.copyDir(File, File),
copyFileToDir(File, File),
copyFile(File, File)public static void move(java.lang.String src,
java.lang.String dest)
throws java.io.IOException
java.io.IOExceptionmove(File, File)public static void move(java.io.File src,
java.io.File dest)
throws java.io.IOException
File to it.
Otherwise, try to move source File to destination File.src - source Filedest - destination Filejava.io.IOException - if there is an error moving.moveDir(File, File),
moveFileToDir(File, File),
moveFile(File, File)public static void delete(java.lang.String dest)
throws java.io.IOException
java.io.IOExceptiondelete(File)public static void delete(java.io.File dest)
throws java.io.IOException
java.io.IOException - if there is an issue deleting the file/directory.deleteFile(File),
deleteDir(File)public static boolean isAncestor(java.io.File ancestor,
java.io.File file,
boolean strict)
File is an ancestor of second one.strict - if c then this method returns true if ancestor
and File are equaltrue if ancestor is parent of File; otherwise, falsepublic static java.io.File getParentFile(java.io.File file)
File names. The name
remains relative if was relative before.
Returns null if the File has no parent.file - Filenull if the File has no parent.public static boolean isFilePathAcceptable(java.io.File file,
java.io.FileFilter fileFilter)
FileFilter.accept(File).file - File to check.fileFilter - FileFilter to use.public static java.io.File createTempDirectory()
throws java.io.IOException
java.io.IOExceptioncreateTempDirectory(String, String)public static java.io.File createTempDirectory(java.lang.String prefix,
java.lang.String suffix)
throws java.io.IOException
java.io.IOExceptioncreateTempDirectory(String, String, File)public static java.io.File createTempDirectory(java.lang.String prefix,
java.lang.String suffix,
java.io.File tempDir)
throws java.io.IOException
java.io.IOExceptioncreateTempFile(String, String, File)public static java.io.File createTempFile()
throws java.io.IOException
java.io.IOExceptioncreateTempFile(String, String, File, boolean)public static java.io.File createTempFile(java.lang.String prefix,
java.lang.String suffix,
java.io.File tempDir,
boolean create)
throws java.io.IOException
File.prefix - The prefix string to be used in generating the file's
name; must be at least three characters longsuffix - The suffix string to be used in generating the file's
name; may be null, in which case the
suffix ".tmp" will be usedtempDir - The directory in which the file is to be created, or
null if the default temporary-file
directory is to be usedcreate - 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.java.io.IOExceptionpublic static java.io.File createTempFile(java.lang.String prefix,
java.lang.String suffix,
java.io.File tempDir)
throws java.io.IOException
File. Wraps Java method and repeats creation several times
if something fails.prefix - The prefix string to be used in generating the file's
name; must be at least three characters longsuffix - The suffix string to be used in generating the file's
name; may be null, in which case the
suffix ".tmp" will be usedtempDir - The directory in which the file is to be created, or
null if the default temporary-file
directory is to be usedjava.io.IOException@Deprecated public static boolean isSymlink(java.io.File file)
Files.isSymbolicLink(java.nio.file.Path) provides this functionality natively as of Java 1.7.public static java.lang.String md5(java.io.File file)
throws java.io.IOException
File.file - File to create digest of.File.java.io.IOExceptionpublic static java.lang.String sha256(java.io.File file)
throws java.io.IOException
file - File to create digest of.File.java.io.IOExceptionpublic static java.lang.String sha512(java.io.File file)
throws java.io.IOException
file - File to create digest of.File.java.io.IOExceptionpublic static boolean isBinary(java.io.File file)
throws java.io.IOException
file - FileFile is ASCII control characters.java.io.IOExceptionCopyright © 2003-present Jodd Team