public class ERXFileUtilities
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static org.apache.log4j.Logger |
log
logging support
|
| Constructor and Description |
|---|
ERXFileUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static NSArray<java.io.File> |
arrayByAddingFilesInDirectory(java.io.File directory,
boolean recursive)
Creates a new NSArray which contains all files in the specified directory.
|
static byte[] |
bytesFromFile(java.io.File f)
Returns the byte array for a given file.
|
static byte[] |
bytesFromFile(java.io.File f,
int n)
Returns an array of the first n bytes for a given file.
|
static byte[] |
bytesFromGZippedFile(java.io.File f)
Returns the byte array for a given gzipped file.
|
static byte[] |
bytesFromInputStream(java.io.InputStream in)
Returns the byte array for a given stream.
|
static byte[] |
bytesFromInputStream(java.io.InputStream fis,
int n)
Returns an array of the first n bytes for a given input stream
|
static java.nio.charset.Charset |
charset() |
static void |
chmod(java.io.File file,
java.lang.String mode)
Java wrapper for call out to chmod.
|
static void |
chmodRecursively(java.io.File dir,
java.lang.String mode)
Java wrapper for call out to chmod with -R parameter for recursive processing.
|
static void |
copyFilesFromDirectory(java.io.File srcDirectory,
java.io.File dstDirectory,
boolean deleteOriginals,
boolean replaceExistingFiles,
boolean recursiveCopy,
java.io.FileFilter filter)
Copies all of the files in a given directory to another directory.
|
static void |
copyFilesFromDirectory(java.io.File srcDirectory,
java.io.File dstDirectory,
boolean deleteOriginals,
boolean recursiveCopy,
java.io.FileFilter filter)
Copies all of the files in a given directory to another directory.
|
static void |
copyFileToFile(java.io.File srcFile,
java.io.File dstFile,
boolean deleteOriginals,
boolean forceDelete)
Copies the source file to the destination.
|
static java.io.File |
createTempDir()
Creates a temporary directory.
|
static java.io.File |
createTempDir(java.lang.String prefix,
java.lang.String suffix)
Creates a temporary directory.
|
static java.lang.String |
datePathWithRoot(java.lang.String rootPath)
Returns a path containing an optional root with a directory hierarchy based on the current time
|
static boolean |
deleteDirectory(java.io.File directory)
Deletes a given directory in a recursive fashion.
|
static boolean |
deleteFile(java.io.File fileToDelete)
Deletes the given file by using the method deleteDirectory.
|
static boolean |
deleteFiles(NSArray<java.io.File> filesToDelete)
Deletes all files in array
filesToDelete by
using the method deleteDirectory. |
static void |
deleteFilesInDirectory(java.io.File directory,
boolean recurseIntoDirectories)
Deletes all of the files in a given directory with the option to
recursively delete all of the directories in the given directory.
|
static void |
deleteFilesInDirectory(java.io.File directory,
java.io.FileFilter filter,
boolean recurseIntoDirectories,
boolean removeDirectories)
Deletes all of the files in a given directory with the option to
recursively delete all of the files in the given directory.
|
static java.lang.String |
fileExtension(java.lang.String name)
returns the fileExtension from the specified filename
|
static java.lang.String |
fileNameFromBrowserSubmittedPath(java.lang.String path)
Returns the file name portion of a browser submitted path.
|
static java.io.InputStream |
inputStreamForResourceNamed(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
Get the input stream from the specified Resource.
|
static long |
lastModifiedDateForFileInFramework(java.lang.String fileName,
java.lang.String frameworkName)
Determines the last modification date for a given file
in a framework.
|
static long |
lastModifiedDateForFileInFramework(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
Determines the last modification date for a given file
in a framework.
|
static long |
length(java.io.File f)
Returns the size of the given file.
|
static void |
linkFiles(java.io.File source,
java.io.File destination,
boolean symbolic,
boolean allowUnlink,
boolean followSymbolicLinks)
Creates a symlink for a given file.
|
static java.io.File[] |
listDirectories(java.io.File baseDir,
boolean recursive)
Lists all directories in the specified directory, is desired recursive.
|
static java.io.File[] |
listFiles(java.io.File baseDir,
boolean recursive,
java.io.FileFilter filter)
Lists all files in the specified directory, if desired recursively.
|
static byte[] |
md5(java.io.File file)
Generate an MD5 hash from a file.
|
static byte[] |
md5(java.io.InputStream in)
Generate an MD5 hash from an input stream.
|
static java.lang.String |
md5Hex(java.io.File file)
Generate an MD5 hash from a file.
|
static java.lang.String |
md5Hex(java.io.InputStream in)
Generate an MD5 hash from an input stream.
|
static java.lang.String |
pathForResourceNamed(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
Determines the path of the specified Resource.
|
static java.net.URL |
pathURLForResourceNamed(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
Determines the path URL of the specified Resource.
|
static java.lang.Object |
readPropertyListFromFileInFramework(java.lang.String fileName,
java.lang.String aFrameWorkName)
Reads a file in from the file system and then parses
it as if it were a property list, using the platform's default encoding.
|
static java.lang.Object |
readPropertyListFromFileInFramework(java.lang.String fileName,
java.lang.String aFrameWorkName,
NSArray<java.lang.String> languageList)
Reads a file in from the file system for the given set
of languages and then parses the file as if it were a
property list, using the platform's default encoding.
|
static java.lang.Object |
readPropertyListFromFileInFramework(java.lang.String fileName,
java.lang.String aFrameWorkName,
NSArray<java.lang.String> languageList,
java.lang.String encoding)
Reads a file in from the file system for the given set
of languages and then parses the file as if it were a
property list, using the specified encoding.
|
static java.lang.Object |
readPropertyListFromFileInFramework(java.lang.String fileName,
java.lang.String aFrameWorkName,
java.lang.String encoding)
Reads a file in from the file system and then parses
it as if it were a property list, using the specified encoding.
|
static void |
remoteCopyFile(java.io.File srcFile,
java.lang.String dstHost,
java.lang.String dstPath)
Copy a file across hosts using scp.
|
static void |
remoteCopyFile(java.lang.String srcHost,
java.lang.String srcPath,
java.io.File dstFile)
Copy a file across hosts using scp.
|
static void |
remoteCopyFile(java.lang.String srcHost,
java.lang.String srcPath,
java.lang.String dstHost,
java.lang.String dstPath)
Copy a file across hosts using scp.
|
static java.lang.String |
removeFileExtension(java.lang.String name)
returns the filename without its fileExtension
|
static void |
renameTo(java.io.File source,
java.io.File destination)
Moves a file from one location to another one.
|
static java.lang.String |
replaceFileExtension(java.lang.String path,
java.lang.String newExtension)
Replaces the extension of the given file with the new extension.
|
static java.io.File |
reserveUniqueFile(java.io.File desiredFile,
boolean overwrite)
Reserves a unique file on the filesystem based on the given file name.
|
static boolean |
resourceExists(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
Determines if a given resource exists.
|
static void |
setDefaultCharset(java.lang.String name) |
static java.lang.String |
shortenFilename(java.lang.String name,
int maxLength)
shortens a filename, for example aVeryLongFileName.java -> aVer...Name.java
|
static java.lang.String |
stringFromFile(java.io.File f)
Returns a string from the file using the default
encoding.
|
static java.lang.String |
stringFromFile(java.io.File f,
java.lang.String encoding)
Returns a string from the file using the specified
encoding.
|
static java.lang.String |
stringFromGZippedFile(java.io.File f)
Returns a string from the gzipped file using the default
encoding.
|
static java.lang.String |
stringFromInputStream(java.io.InputStream in)
Returns a string from the input stream using the default
encoding.
|
static java.lang.String |
stringFromInputStream(java.io.InputStream in,
java.lang.String encoding)
Returns a string from the input stream using the specified
encoding.
|
static java.lang.String |
stringFromURL(java.net.URL url)
Returns the String from the contents of the given URL.
|
static void |
stringToFile(java.lang.String s,
java.io.File f)
Writes the contents of
s to f
using the platform's default encoding. |
static void |
stringToFile(java.lang.String s,
java.io.File f,
java.lang.String encoding)
Writes the contents of
s to f
using specified encoding. |
static void |
stringToGZippedFile(java.lang.String s,
java.io.File f) |
static java.io.File |
unzipFile(java.io.File f,
java.io.File destination)
Decompresses the specified zipfile.
|
static java.net.URL |
URLFromFile(java.io.File file)
Create an URL for a given file.
|
static java.net.URL |
URLFromPath(java.lang.String fileName)
Create an URL for a given path.
|
static void |
writeInputStreamToFile(java.io.File f,
java.io.InputStream is)
Deprecated.
|
static void |
writeInputStreamToFile(java.io.InputStream stream,
java.io.File file)
Writes the contents of an InputStream to a specified file.
|
static void |
writeInputStreamToGZippedFile(java.io.InputStream stream,
java.io.File file) |
static void |
writeInputStreamToOutputStream(java.io.InputStream in,
boolean closeInputStream,
java.io.OutputStream out,
boolean closeOutputStream)
Copies the contents of the input stream to the given output stream.
|
static void |
writeInputStreamToOutputStream(java.io.InputStream in,
java.io.OutputStream out)
Copies the contents of the input stream to the given output stream.
|
static java.io.File |
writeInputStreamToTempFile(java.io.InputStream stream)
Writes the contents of an InputStream to a temporary file.
|
static java.io.File |
writeInputStreamToTempFile(java.io.InputStream stream,
java.lang.String prefix,
java.lang.String suffix)
Writes the contents of an InputStream to a temporary file.
|
static void |
writeUrlToTempFile(java.lang.String url,
java.io.File file)
Copies the contents of the given URL to a file.
|
static java.io.File |
writeUrlToTempFile(java.lang.String url,
java.lang.String prefix,
java.lang.String suffix)
Copies the contents of the given URL to a temporary file.
|
static void |
writeUrlToTempFile(java.net.URL url,
java.io.File file)
Copies the contents of the given URL to a file.
|
static java.io.File |
writeUrlToTempFile(java.net.URL url,
java.lang.String prefix,
java.lang.String suffix)
Copies the contents of the given URL to a temporary file.
|
static java.io.File |
zipFile(java.io.File f,
boolean absolutePaths,
boolean deleteOriginal,
boolean forceDelete)
Compresses a given File with zip.
|
static java.io.File |
zipFile(java.io.File f,
boolean absolutePaths,
boolean deleteOriginal,
boolean forceDelete,
int level)
Compresses a given File with zip.
|
public static java.nio.charset.Charset charset()
public static void setDefaultCharset(java.lang.String name)
public static java.io.File writeUrlToTempFile(java.lang.String url,
java.lang.String prefix,
java.lang.String suffix)
throws java.io.IOException
url - the URL to copy fromprefix - the temporary file prefixsuffix - the temporary file suffix (if null, the extension from the URL is used)java.io.IOException - if the copy failspublic static java.io.File writeUrlToTempFile(java.net.URL url,
java.lang.String prefix,
java.lang.String suffix)
throws java.io.IOException
url - the URL to copy fromprefix - the temporary file prefixsuffix - the temporary file suffix (if null, the extension from the URL is used)java.io.IOException - if the copy failspublic static void writeUrlToTempFile(java.lang.String url,
java.io.File file)
throws java.io.IOException
url - the URL to copy fromfile - the File to write tojava.io.IOException - if the copy failspublic static void writeUrlToTempFile(java.net.URL url,
java.io.File file)
throws java.io.IOException
url - the URL to copy fromfile - the File to write tojava.io.IOException - if the copy failspublic static byte[] bytesFromInputStream(java.io.InputStream in)
throws java.io.IOException
in - stream to get the bytes fromjava.io.IOException - if things go wrongpublic static java.lang.String stringFromInputStream(java.io.InputStream in,
java.lang.String encoding)
throws java.io.IOException
in - stream to readencoding - to be used, null will use the defaultjava.io.IOException - if things go wrongpublic static java.lang.String stringFromInputStream(java.io.InputStream in)
throws java.io.IOException
in - stream to readjava.io.IOException - if things go wrongpublic static java.lang.String stringFromURL(java.net.URL url)
throws java.io.IOException
url - the URL to read fromjava.io.IOException - if an error occurspublic static byte[] bytesFromGZippedFile(java.io.File f)
throws java.io.IOException
f - file to get the bytes fromjava.io.IOException - if things go wrongpublic static byte[] bytesFromFile(java.io.File f)
throws java.io.IOException
f - file to get the bytes fromjava.io.IOException - if things go wrongpublic static byte[] bytesFromFile(java.io.File f,
int n)
throws java.io.IOException
f - file to get the bytes fromn - number of bytes to read from input filejava.io.IOException - if things go wrongpublic static byte[] bytesFromInputStream(java.io.InputStream fis,
int n)
throws java.io.IOException
fis - inputstream to get the bytes fromn - number of bytes to read from input streamjava.io.IOException - if things go wrong@Deprecated
public static void writeInputStreamToFile(java.io.File f,
java.io.InputStream is)
throws java.io.IOException
writeInputStreamToFile(InputStream, File)java.io.IOExceptionpublic static java.io.File writeInputStreamToTempFile(java.io.InputStream stream)
throws java.io.IOException
stream - to pull data fromjava.io.IOException - if things go wrongpublic static java.io.File writeInputStreamToTempFile(java.io.InputStream stream,
java.lang.String prefix,
java.lang.String suffix)
throws java.io.IOException
stream - to pull data fromprefix - the filename prefix of the temp filesuffix - the filename suffix of the temp filejava.io.IOException - if things go wrongpublic static void writeInputStreamToFile(java.io.InputStream stream,
java.io.File file)
throws java.io.IOException
file - to write tostream - to pull data fromjava.io.IOException - if things go wrongpublic static void writeInputStreamToGZippedFile(java.io.InputStream stream,
java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static void writeInputStreamToOutputStream(java.io.InputStream in,
java.io.OutputStream out)
throws java.io.IOException
in - the input stream to copy fromout - the output stream to copy tojava.io.IOException - if there is any failurepublic static void writeInputStreamToOutputStream(java.io.InputStream in,
boolean closeInputStream,
java.io.OutputStream out,
boolean closeOutputStream)
throws java.io.IOException
in - the input stream to copy fromcloseInputStream - if true, the input stream will be closedout - the output stream to copy tocloseOutputStream - if true, the output stream will be closedjava.io.IOException - if there is any failurepublic static void stringToGZippedFile(java.lang.String s,
java.io.File f)
throws java.io.IOException
java.io.IOExceptionpublic static void stringToFile(java.lang.String s,
java.io.File f)
throws java.io.IOException
s to f
using the platform's default encoding.s - the string to be written to filef - the destination filejava.io.IOException - if things go wrongpublic static void stringToFile(java.lang.String s,
java.io.File f,
java.lang.String encoding)
throws java.io.IOException
s to f
using specified encoding.s - the string to be written to filef - the destination fileencoding - the desired encodingjava.io.IOException - if things go wrongpublic static void remoteCopyFile(java.lang.String srcHost,
java.lang.String srcPath,
java.lang.String dstHost,
java.lang.String dstPath)
throws java.io.IOException
srcHost - host to send from (null if file is local)srcPath - path on srcHost to read fromdstHost - host to send to (null if file is local)dstPath - path on srcHost to write tojava.io.IOException - if things go wrongpublic static void remoteCopyFile(java.io.File srcFile,
java.lang.String dstHost,
java.lang.String dstPath)
throws java.io.IOException
srcFile - local file to senddstHost - host to send to (null if file is local)dstPath - path on srcHost to write tojava.io.IOException - if things go wrongpublic static void remoteCopyFile(java.lang.String srcHost,
java.lang.String srcPath,
java.io.File dstFile)
throws java.io.IOException
srcHost - host to send from (null if file is local)srcPath - path on srcHost to read fromdstFile - local file to write tojava.io.IOException - if things go wrongpublic static java.lang.String stringFromGZippedFile(java.io.File f)
throws java.io.IOException
f - file to readjava.io.IOException - if things go wrongpublic static java.lang.String stringFromFile(java.io.File f)
throws java.io.IOException
f - file to readjava.io.IOException - if things go wrongpublic static java.lang.String stringFromFile(java.io.File f,
java.lang.String encoding)
throws java.io.IOException
f - file to readencoding - to be used, null will use the defaultjava.io.IOException - if things go wrongpublic static java.lang.String pathForResourceNamed(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
fileName - name of the fileframeworkName - name of the framework, null or "app"
for the application bundlelanguages - array of languages to get localized resource or nullpublic static boolean resourceExists(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
fileName - name of the fileframeworkName - name of the framework, null or "app"
for the application bundlelanguages - array of languages to get localized resource or nullpublic static java.io.InputStream inputStreamForResourceNamed(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
fileName - name of the fileframeworkName - name of the framework, null or "app"
for the application bundlelanguages - array of languages to get localized resource or nullpublic static java.lang.String datePathWithRoot(java.lang.String rootPath)
rootPath - Root of the path before the above the date directoriespublic static java.net.URL pathURLForResourceNamed(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
fileName - name of the fileframeworkName - name of the framework, null or "app"
for the application bundlelanguages - array of languages to get localized resource or nullpublic static java.net.URL URLFromFile(java.io.File file)
file - name of the filepublic static java.net.URL URLFromPath(java.lang.String fileName)
fileName - path of the filepublic static long lastModifiedDateForFileInFramework(java.lang.String fileName,
java.lang.String frameworkName)
fileName - name of the fileframeworkName - name of the framework, null or "app"
for the application bundlelastModified method off of the
file objectpublic static long lastModifiedDateForFileInFramework(java.lang.String fileName,
java.lang.String frameworkName,
NSArray<java.lang.String> languages)
fileName - name of the fileframeworkName - name of the framework, null or "app"
for the application bundlelanguages - array of languages to get localized resource or nulllastModified method off of the file objectpublic static java.lang.Object readPropertyListFromFileInFramework(java.lang.String fileName,
java.lang.String aFrameWorkName)
fileName - name of the fileaFrameWorkName - name of the framework, null or
'app' for the application bundle.public static java.lang.Object readPropertyListFromFileInFramework(java.lang.String fileName,
java.lang.String aFrameWorkName,
java.lang.String encoding)
fileName - name of the fileaFrameWorkName - name of the framework, null or
'app' for the application bundle.encoding - the encoding used with fileNamepublic static java.lang.Object readPropertyListFromFileInFramework(java.lang.String fileName,
java.lang.String aFrameWorkName,
NSArray<java.lang.String> languageList)
fileName - name of the fileaFrameWorkName - name of the framework, null or
'app' for the application bundle.languageList - language list search orderpublic static java.lang.Object readPropertyListFromFileInFramework(java.lang.String fileName,
java.lang.String aFrameWorkName,
NSArray<java.lang.String> languageList,
java.lang.String encoding)
fileName - name of the fileaFrameWorkName - name of the framework, null or
'app' for the application bundle.languageList - language list search orderencoding - the encoding used with fileNamepublic static void deleteFilesInDirectory(java.io.File directory,
boolean recurseIntoDirectories)
directory - to delete all of the files fromrecurseIntoDirectories - determines if the delete is recursivepublic static void deleteFilesInDirectory(java.io.File directory,
java.io.FileFilter filter,
boolean recurseIntoDirectories,
boolean removeDirectories)
directory - to delete all of the files fromfilter - optional FileFilter to restrict what gets deleted, null to delete everythingrecurseIntoDirectories - determines if the delete is recursiveremoveDirectories - true if directories should be removed as well as files, false to only remove filespublic static boolean deleteDirectory(java.io.File directory)
directory - to be deletedpublic static void chmod(java.io.File file,
java.lang.String mode)
throws java.io.IOException
file - the File to run chmod onmode - see the chmod man pagejava.io.IOException - if things go wrongpublic static void chmodRecursively(java.io.File dir,
java.lang.String mode)
throws java.io.IOException
dir - the File to run chmod onmode - see the chmod man pagejava.io.IOException - if things go wrongpublic static void linkFiles(java.io.File source,
java.io.File destination,
boolean symbolic,
boolean allowUnlink,
boolean followSymbolicLinks)
throws java.io.IOException
source - to create the link todestination - file to create the link tosymbolic - determines if a symlink should be createdallowUnlink - determines if the symlink is a hardlink which allows unlinkingfollowSymbolicLinks - If the destination is a symbolic link, follow itjava.io.IOException - if the link could not be createdpublic static void copyFilesFromDirectory(java.io.File srcDirectory,
java.io.File dstDirectory,
boolean deleteOriginals,
boolean recursiveCopy,
java.io.FileFilter filter)
throws java.io.IOException
srcDirectory - source directorydstDirectory - destination directorydeleteOriginals - tells if the original files, the file is deleted even if appuser has no write
rights. This is compareable to a rm -f filename instead of rm filenamerecursiveCopy - specifies if directories should be recursively copiedfilter - which restricts the files to be copiedjava.io.IOException - if things go wrongpublic static void copyFilesFromDirectory(java.io.File srcDirectory,
java.io.File dstDirectory,
boolean deleteOriginals,
boolean replaceExistingFiles,
boolean recursiveCopy,
java.io.FileFilter filter)
throws java.io.IOException
srcDirectory - source directorydstDirectory - destination directorydeleteOriginals - tells if the original files, the file is deleted even if appuser has no write
rights. This is comparable to a rm -f filename instead of rm filenamereplaceExistingFiles - true if the destination should be overwritten if it already existsrecursiveCopy - specifies if directories should be recursively copiedfilter - which restricts the files to be copiedjava.io.IOException - if things go wrongpublic static void copyFileToFile(java.io.File srcFile,
java.io.File dstFile,
boolean deleteOriginals,
boolean forceDelete)
throws java.io.IOException
dstFile if they are missing.srcFile - source filedstFile - destination file which may or may not exist already. If it exists, its contents will be overwritten.deleteOriginals - if true then srcFile will be deleted. Note that if the appuser has no write rights
on srcFile it is NOT deleted unless forceDelete is trueforceDelete - if true then missing write rights are ignored and the file is deleted.java.io.IOException - if things go wrongpublic static final java.io.File createTempDir()
throws java.io.IOException
java.io.IOException - if something goes wrongpublic static final java.io.File createTempDir(java.lang.String prefix,
java.lang.String suffix)
throws java.io.IOException
prefix - prefix to use for the filenamesuffix - suffix to use for the filenamejava.io.IOException - if something goes wrongpublic static NSArray<java.io.File> arrayByAddingFilesInDirectory(java.io.File directory, boolean recursive)
directory - the directory from which to add the filesrecursive - if true then files are added recursively meaning subdirectories are scanned, too.public static java.lang.String replaceFileExtension(java.lang.String path,
java.lang.String newExtension)
path - the path of the file.newExtension - the new extension.public static java.io.File unzipFile(java.io.File f,
java.io.File destination)
throws java.io.IOException
null
then the System Property "java.io.tmpdir" is used as destination for the
uncompressed file(s).f - The file to unzipdestination - the destination directory. If directory is null then the file will be unzipped in
java.io.tmpdir, if it does not exist, then a directory is created and if it exists but is a file
then the destination is set to the directory in which the file is located.java.io.IOException - if something goes wrongpublic static java.io.File zipFile(java.io.File f,
boolean absolutePaths,
boolean deleteOriginal,
boolean forceDelete)
throws java.io.IOException
f - the file to zip, either a file or a directoryabsolutePaths - if true then the files are added with absolute pathsdeleteOriginal - if true then the original file is deletedforceDelete - if true then the original is deleted even if the file is read onlyjava.io.IOException - if something goes wrongpublic static java.io.File zipFile(java.io.File f,
boolean absolutePaths,
boolean deleteOriginal,
boolean forceDelete,
int level)
throws java.io.IOException
f - the file to zip, either a file or a directoryabsolutePaths - if true then the files are added with absolute pathsdeleteOriginal - if true then the original file is deletedforceDelete - if true then the original is deleted even if the file is read onlylevel - the compression level (0-9)java.io.IOException - if something goes wrongpublic static byte[] md5(java.io.File file)
throws java.io.IOException
file - the file to sumjava.io.IOException - if file could not be readpublic static byte[] md5(java.io.InputStream in)
throws java.io.IOException
in - the input stream to sumjava.io.IOException - if the input stream could not be readpublic static java.lang.String md5Hex(java.io.File file)
throws java.io.IOException
file - the file to sumjava.io.IOException - if the file could not be readpublic static java.lang.String md5Hex(java.io.InputStream in)
throws java.io.IOException
in - the input stream to sumjava.io.IOException - if the input stream could not be readpublic static long length(java.io.File f)
f points
to a directory the size of all its children will be computed.f - file to get the size ofpublic static java.lang.String shortenFilename(java.lang.String name,
int maxLength)
name - the name to modifymaxLength - the maximum length of the name.
maxLength values under 4 have no effect, the returned string is
always a....javapublic static java.lang.String removeFileExtension(java.lang.String name)
name - the name of the filepublic static java.lang.String fileExtension(java.lang.String name)
name - the name of the filepublic static boolean deleteFiles(NSArray<java.io.File> filesToDelete)
filesToDelete by
using the method deleteDirectory.filesToDelete - array of files to deletetrue if all file have been deleted,
false otherwisepublic static boolean deleteFile(java.io.File fileToDelete)
fileToDelete - file to deletetrue if file has been deleted,
false otherwisepublic static java.io.File[] listDirectories(java.io.File baseDir,
boolean recursive)
baseDir - the dir from which to list the child directoriesrecursive - if true this methods works recursivelypublic static java.io.File[] listFiles(java.io.File baseDir,
boolean recursive,
java.io.FileFilter filter)
baseDir - the dir from which to list the child filesrecursive - if true this method works recursivelyfilter - filter to match the files against. If null, all files will be included.public static void renameTo(java.io.File source,
java.io.File destination)
throws java.io.IOException
source - the file to movedestination - the destination to move the source tojava.io.IOException - if things go wrongpublic static java.lang.String fileNameFromBrowserSubmittedPath(java.lang.String path)
path - the full path from the browserpublic static java.io.File reserveUniqueFile(java.io.File desiredFile,
boolean overwrite)
throws java.io.IOException
desiredFile - the desired destination file to writeoverwrite - if true, this will immediately return desiredFilejava.io.IOException - if the file cannot be createdCopyright © 2002 – 2022 Project Wonder.