
Static Public Member Functions | |
| static NSArray< File > | arrayByAddingFilesInDirectory (File directory, boolean recursive) |
| static byte[] | bytesFromFile (File f, int n) throws IOException |
| static byte[] | bytesFromFile (File f) throws IOException |
| static byte[] | bytesFromGZippedFile (File f) throws IOException |
| static byte[] | bytesFromInputStream (InputStream fis, int n) throws IOException |
| static byte[] | bytesFromInputStream (InputStream in) throws IOException |
| static void | chmod (File file, String mode) throws IOException |
| static void | chmodRecursively (File dir, String mode) throws IOException |
| static void | copyFilesFromDirectory (File srcDirectory, File dstDirectory, boolean deleteOriginals, boolean replaceExistingFiles, boolean recursiveCopy, FileFilter filter) throws FileNotFoundException, IOException |
| static void | copyFilesFromDirectory (File srcDirectory, File dstDirectory, boolean deleteOriginals, boolean recursiveCopy, FileFilter filter) throws FileNotFoundException, IOException |
| static void | copyFileToFile (File srcFile, File dstFile, boolean deleteOriginals, boolean forceDelete) throws FileNotFoundException, IOException |
| static final File | createTempDir (String prefix, String suffix) throws IOException |
| static final File | createTempDir () throws IOException |
| static String | datePathWithRoot (String rootPath) |
| static boolean | deleteDirectory (File directory) |
| static boolean | deleteFile (File fileToDelete) |
| static boolean | deleteFiles (NSMutableArray filesToDelete) |
| static void | deleteFilesInDirectory (File directory, FileFilter filter, boolean recurseIntoDirectories, boolean removeDirectories) |
| static void | deleteFilesInDirectory (File directory, boolean recurseIntoDirectories) |
| static String | fileExtension (String name) |
| static String | fileNameFromBrowserSubmittedPath (String path) |
| static InputStream | inputStreamForResourceNamed (String fileName, String frameworkName, NSArray languages) |
| static long | lastModifiedDateForFileInFramework (String fileName, String frameworkName) |
| static long | length (File f) |
| static void | linkFiles (File source, File destination, boolean symbolic, boolean allowUnlink, boolean followSymbolicLinks) throws IOException |
| static File[] | listDirectories (File baseDir, boolean recursive) |
| static File[] | listFiles (File baseDir, boolean recursive, FileFilter filter) |
| static byte[] | md5 (InputStream in) throws IOException |
| static byte[] | md5 (File file) throws IOException |
| static String | md5Hex (InputStream in) throws IOException |
| static String | md5Hex (File file) throws IOException |
| static String | pathForResourceNamed (String fileName, String frameworkName, NSArray languages) |
| static URL | pathURLForResourceNamed (String fileName, String frameworkName, NSArray languages) |
| static Object | readPropertyListFromFileInFramework (String fileName, String aFrameWorkName, NSArray languageList, String encoding) |
| static Object | readPropertyListFromFileInFramework (String fileName, String aFrameWorkName, NSArray languageList) |
| static Object | readPropertyListFromFileInFramework (String fileName, String aFrameWorkName, String encoding) |
| static Object | readPropertyListFromFileInFramework (String fileName, String aFrameWorkName) |
| static void | remoteCopyFile (String srcHost, String srcPath, File dstFile) throws IOException |
| static void | remoteCopyFile (File srcFile, String dstHost, String dstPath) throws IOException |
| static void | remoteCopyFile (String srcHost, String srcPath, String dstHost, String dstPath) throws IOException |
| static String | removeFileExtension (String name) |
| static void | renameTo (File source, File destination) throws FileNotFoundException, IOException |
| static String | replaceFileExtension (String path, String newExtension) |
| static File | reserveUniqueFile (File desiredFile, boolean overwrite) throws IOException |
| static boolean | resourceExists (String fileName, String frameworkName, NSArray languages) |
| static String | shortenFilename (String name, int maxLength) |
| static String | stringFromFile (File f, String encoding) throws IOException |
| static String | stringFromFile (File f) throws IOException |
| static String | stringFromGZippedFile (File f) throws IOException |
| static String | stringFromInputStream (InputStream in) throws IOException |
| static String | stringFromInputStream (InputStream in, String encoding) throws IOException |
| static String | stringFromURL (URL url) throws IOException |
| static void | stringToFile (String s, File f, String encoding) throws IOException |
| static void | stringToFile (String s, File f) throws IOException |
| static void | stringToGZippedFile (String s, File f) throws IOException |
| static File | unzipFile (File f, File destination) throws IOException |
| static URL | URLFromFile (File file) |
| static URL | URLFromPath (String fileName) |
| static void | writeInputStreamToFile (InputStream stream, File file) throws IOException |
| static void | writeInputStreamToFile (File f, InputStream is) throws IOException |
| static void | writeInputStreamToGZippedFile (InputStream stream, File file) throws IOException |
| static void | writeInputStreamToOutputStream (InputStream in, boolean closeInputStream, OutputStream out, boolean closeOutputStream) throws IOException |
| static void | writeInputStreamToOutputStream (InputStream in, OutputStream out) throws IOException |
| static File | writeInputStreamToTempFile (InputStream stream, String prefix, String suffix) throws IOException |
| static File | writeInputStreamToTempFile (InputStream stream) throws IOException |
| static void | writeUrlToTempFile (URL url, File file) throws IOException |
| static void | writeUrlToTempFile (String url, File file) throws IOException |
| static File | writeUrlToTempFile (URL url, String prefix, String suffix) throws IOException |
| static File | writeUrlToTempFile (String url, String prefix, String suffix) throws IOException |
| static File | zipFile (File f, boolean absolutePaths, boolean deleteOriginal, boolean forceDelete, int level) throws IOException |
| static File | zipFile (File f, boolean absolutePaths, boolean deleteOriginal, boolean forceDelete) throws IOException |
Static Public Attributes | |
| static final Logger | log = Logger.getLogger(ERXFileUtilities.class) |
| static NSArray<File> arrayByAddingFilesInDirectory | ( | File | directory, | |
| boolean | recursive | |||
| ) | [static] |
Creates a new NSArray which contains all files in the specified directory.
| directory | the directory from which to add the files | |
| recursive | if true then files are added recursively meaning subdirectories are scanned, too. |
| static byte [] bytesFromFile | ( | File | f, | |
| int | n | |||
| ) | throws IOException [static] |
Returns an array of the first n bytes for a given file.
| f | file to get the bytes from | |
| n | number of bytes to read from input file |
| IOException | if things go wrong |
| static byte [] bytesFromFile | ( | File | f | ) | throws IOException [static] |
Returns the byte array for a given file.
| f | file to get the bytes from |
| IOException | if things go wrong |
| static byte [] bytesFromGZippedFile | ( | File | f | ) | throws IOException [static] |
Returns the byte array for a given gzipped file.
| f | file to get the bytes from |
| IOException | if things go wrong |
| static byte [] bytesFromInputStream | ( | InputStream | fis, | |
| int | n | |||
| ) | throws IOException [static] |
Returns an array of the first n bytes for a given input stream
| fis | inputstream to get the bytes from | |
| n | number of bytes to read from input stream |
| IOException | if things go wrong |
| static byte [] bytesFromInputStream | ( | InputStream | in | ) | throws IOException [static] |
Returns the byte array for a given stream.
| in | stream to get the bytes from |
| IOException | if things go wrong |
| static void chmod | ( | File | file, | |
| String | mode | |||
| ) | throws IOException [static] |
Java wrapper for call out to chmod. Only works if your OS supports the chmod command.
| file | the File to run chmod on | |
| mode | see the chmod man page |
| IOException | if things go wrong |
| static void chmodRecursively | ( | File | dir, | |
| String | mode | |||
| ) | throws IOException [static] |
Java wrapper for call out to chmod with -R parameter for recursive processing. Only works if your OS supports the chmod command.
| dir | the File to run chmod on | |
| mode | see the chmod man page |
| IOException | if things go wrong |
| static void copyFilesFromDirectory | ( | File | srcDirectory, | |
| File | dstDirectory, | |||
| boolean | deleteOriginals, | |||
| boolean | replaceExistingFiles, | |||
| boolean | recursiveCopy, | |||
| FileFilter | filter | |||
| ) | throws FileNotFoundException, IOException [static] |
Copies all of the files in a given directory to another directory.
| srcDirectory | source directory | |
| dstDirectory | destination directory | |
| deleteOriginals | 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 filename | |
| replaceExistingFiles | true if the destination should be overwritten if it already exists | |
| recursiveCopy | specifies if directories should be recursively copied | |
| filter | which restricts the files to be copied |
| static void copyFilesFromDirectory | ( | File | srcDirectory, | |
| File | dstDirectory, | |||
| boolean | deleteOriginals, | |||
| boolean | recursiveCopy, | |||
| FileFilter | filter | |||
| ) | throws FileNotFoundException, IOException [static] |
Copies all of the files in a given directory to another directory. Existing files are replaced.
| srcDirectory | source directory | |
| dstDirectory | destination directory | |
| deleteOriginals | 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 filename | |
| recursiveCopy | specifies if directories should be recursively copied | |
| filter | which restricts the files to be copied |
| static void copyFileToFile | ( | File | srcFile, | |
| File | dstFile, | |||
| boolean | deleteOriginals, | |||
| boolean | forceDelete | |||
| ) | throws FileNotFoundException, IOException [static] |
Copys the source file to the destination
| srcFile | source file | |
| dstFile | destination file | |
| deleteOriginals | tells if original file will be deleted. Note that if the appuser has no write rights on the file it is NOT deleted unless force delete is true | |
| forceDelete | if true then missing write rights are ignored and the file is deleted. |
Creates a temporary directory.
| IOException | if something goes wrong |
| static final File createTempDir | ( | ) | throws IOException [static] |
Creates a temporary directory.
| IOException | if something goes wrong |
Returns a path containing an optional root with a directory hierarchy based on the current time
| rootPath | Root of the path before the above the date directories |
| static boolean deleteDirectory | ( | File | directory | ) | [static] |
Deletes a given directory in a recursive fashion.
| directory | to be deleted |
| static boolean deleteFile | ( | File | fileToDelete | ) | [static] |
| static boolean deleteFiles | ( | NSMutableArray | filesToDelete | ) | [static] |
Deletes all files in filesToDelete uses the methdo deleteDirectory
| filesToDelete |
| static void deleteFilesInDirectory | ( | File | directory, | |
| FileFilter | filter, | |||
| boolean | recurseIntoDirectories, | |||
| boolean | removeDirectories | |||
| ) | [static] |
Deletes all of the files in a given directory with the option to recursively delete all of the files in the given directory.
| directory | to delete all of the files from | |
| filter | optional FileFilter to restrict what gets deleted, null to delete everything | |
| recurseIntoDirectories | determines if the delete is recursive | |
| removeDirectories | true if directories should be removed as well as files, false to only remove files |
| static void deleteFilesInDirectory | ( | File | directory, | |
| boolean | recurseIntoDirectories | |||
| ) | [static] |
Deletes all of the files in a given directory with the option to recursively delete all of the directories in the given directory.
| directory | to delete all of the files from | |
| recurseIntoDirectories | determines if the delete is recursive |
returns the fileExtension from the specified filename
| name | the name of the file |
Returns the file name portion of a browser submitted path.
| path | the full path from the browser |
| static InputStream inputStreamForResourceNamed | ( | String | fileName, | |
| String | frameworkName, | |||
| NSArray | languages | |||
| ) | [static] |
Get the input stream from the specified Resource.
| fileName | name of the file | |
| frameworkName | name of the framework, null or "app" for the application bundle |
Determines the last modification date for a given file in a framework. Note that this method will only test for the global resource not the localized resources.
| fileName | name of the file | |
| frameworkName | name of the framework, null or "app" for the application bundle |
lastModified method off of the file object | static long length | ( | File | f | ) | [static] |
| static void linkFiles | ( | File | source, | |
| File | destination, | |||
| boolean | symbolic, | |||
| boolean | allowUnlink, | |||
| boolean | followSymbolicLinks | |||
| ) | throws IOException [static] |
Creates a symlink for a given file. Note this only works on civilized OSs which support symbolic linking.
| source | to create the link to | |
| destination | file to create the link to | |
| symbolic | determines if a symlink should be created | |
| allowUnlink | determines if the symlink is a hardlink which allows unlinking | |
| followSymbolicLinks | If the destination is a symbolic link, follow it |
| IOException |
| static File [] listDirectories | ( | File | baseDir, | |
| boolean | recursive | |||
| ) | [static] |
Lists all directories in the specified directory, is desired recursive.
| baseDir | the dir from which to list the child directories | |
| recursive | if true this methods works recursively |
| static File [] listFiles | ( | File | baseDir, | |
| boolean | recursive, | |||
| FileFilter | filter | |||
| ) | [static] |
Lists all files in the specified directory, if desired recursively.
| baseDir | the dir from which to list the child files | |
| recursive | if true this method works recursively | |
| filter | filter to match the files against. If null, all files will be included. |
| static byte [] md5 | ( | InputStream | in | ) | throws IOException [static] |
Generate an MD5 hash from an input stream.
| in | the input stream to sum |
| IOException |
| static byte [] md5 | ( | File | file | ) | throws IOException [static] |
Generate an MD5 hash from a file.
| file | the file to sum |
| IOException |
| static String md5Hex | ( | InputStream | in | ) | throws IOException [static] |
Generate an MD5 hash from an input stream.
| in | the input stream to sum |
| IOException |
| static String md5Hex | ( | File | file | ) | throws IOException [static] |
Generate an MD5 hash from a file.
| file | the file to sum |
| IOException |
| static String pathForResourceNamed | ( | String | fileName, | |
| String | frameworkName, | |||
| NSArray | languages | |||
| ) | [static] |
Determines the path of the specified Resource. This is done to get a single entry point due to the deprecation of pathForResourceNamed
| fileName | name of the file | |
| frameworkName | name of the framework, null or "app" for the application bundle |
| static URL pathURLForResourceNamed | ( | String | fileName, | |
| String | frameworkName, | |||
| NSArray | languages | |||
| ) | [static] |
Determines the path URL of the specified Resource. This is done to get a single entry point due to the deprecation of pathForResourceNamed. In a later version this will call out to the resource managers new methods directly.
| fileName | name of the file | |
| frameworkName | name of the framework, null or "app" for the application bundle |
| static Object readPropertyListFromFileInFramework | ( | String | fileName, | |
| String | aFrameWorkName, | |||
| NSArray | languageList, | |||
| String | encoding | |||
| ) | [static] |
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.
| fileName | name of the file | |
| aFrameWorkName | name of the framework, null or 'app' for the application bundle. | |
| languageList | language list search order | |
| encoding | the encoding used with fileName |
| static Object readPropertyListFromFileInFramework | ( | String | fileName, | |
| String | aFrameWorkName, | |||
| NSArray | languageList | |||
| ) | [static] |
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.
| fileName | name of the file | |
| aFrameWorkName | name of the framework, null or 'app' for the application bundle. | |
| languageList | language list search order |
| static Object readPropertyListFromFileInFramework | ( | String | fileName, | |
| String | aFrameWorkName, | |||
| String | encoding | |||
| ) | [static] |
Reads a file in from the file system and then parses it as if it were a property list, using the specified encoding.
| fileName | name of the file | |
| aFrameWorkName | name of the framework, null or 'app' for the application bundle. | |
| encoding | the encoding used with fileName |
| static Object readPropertyListFromFileInFramework | ( | String | fileName, | |
| String | aFrameWorkName | |||
| ) | [static] |
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.
| fileName | name of the file | |
| aFrameWorkName | name of the framework, null or 'app' for the application bundle. |
| static void remoteCopyFile | ( | String | srcHost, | |
| String | srcPath, | |||
| File | dstFile | |||
| ) | throws IOException [static] |
Copy a file across hosts using scp.
| srcHost | host to send from (null if file is local) | |
| srcPath | path on srcHost to read from | |
| dstFile | local file to write to |
| static void remoteCopyFile | ( | File | srcFile, | |
| String | dstHost, | |||
| String | dstPath | |||
| ) | throws IOException [static] |
Copy a file across hosts using scp.
| srcFile | local file to send | |
| dstHost | host to send to (null if file is local) | |
| dstPath | path on srcHost to write to |
| static void remoteCopyFile | ( | String | srcHost, | |
| String | srcPath, | |||
| String | dstHost, | |||
| String | dstPath | |||
| ) | throws IOException [static] |
Copy a file across hosts using scp.
| srcHost | host to send from (null if file is local) | |
| srcPath | path on srcHost to read from | |
| dstHost | host to send to (null if file is local) | |
| dstPath | path on srcHost to write to |
returns the filename without its fileExtension
| name | the name of the file |
| static void renameTo | ( | File | source, | |
| File | destination | |||
| ) | throws FileNotFoundException, IOException [static] |
moves a file from one location to another one. This works different than java.io.File.renameTo as renameTo does not work across partitions
| source | ||
| destination |
| IOException | ||
| FileNotFoundException |
Replaces the extension of the given file with the new extension.
| path | the path of the file. | |
| newExtension | the new extension. |
| static File reserveUniqueFile | ( | File | desiredFile, | |
| boolean | overwrite | |||
| ) | throws IOException [static] |
Reserves a unique file on the filesystem based on the given file name. If the given file cannot be reserved, then "-1", "-2", etc will be appended to the filename in front of the extension until a unique file name is found. This will also ensure that the parent folder is created.
| desiredFile | the desired destination file to write | |
| overwrite | if true, this will immediately return desiredFile |
| IOException | if the file cannot be created |
Determines if a given resource exists. This is done to get a single entry point due to the deprecation of pathForResourceNamed
| fileName | name of the file | |
| frameworkName | name of the framework, null or "app" for the application bundle |
shortens a filename, for example aVeryLongFileName.java -> aVer...Name.java
| name | the name to modify | |
| maxLength | the maximum length of the name. maxLength values under 4 have no effect, the returned string is always a....java |
Returns a string from the file using the specified encoding.
| f | file to read | |
| encoding | to be used, null will use the default |
| static String stringFromFile | ( | File | f | ) | throws IOException [static] |
Returns a string from the file using the default encoding.
| f | file to read |
| static String stringFromGZippedFile | ( | File | f | ) | throws IOException [static] |
Returns a string from the gzipped file using the default encoding.
| f | file to read |
| static String stringFromInputStream | ( | InputStream | in | ) | throws IOException [static] |
Returns a string from the input stream using the default encoding.
| in | stream to read |
Returns a string from the input stream using the specified encoding.
| in | stream to read | |
| encoding | to be used, null will use the default |
| static String stringFromURL | ( | URL | url | ) | throws IOException [static] |
Returns the String from the contents of the given URL.
| url | the URL to read from |
| IOException | if an error occurs |
Writes the contents of s to f using specified encoding.
| s | the string to be written to file | |
| f | the destination file | |
| encoding | the desired encoding |
| static void stringToFile | ( | String | s, | |
| File | f | |||
| ) | throws IOException [static] |
Writes the contents of s to f using the platform's default encoding.
| s | the string to be written to file | |
| f | the destination file |
| static void stringToGZippedFile | ( | String | s, | |
| File | f | |||
| ) | throws IOException [static] |
| static File unzipFile | ( | File | f, | |
| File | destination | |||
| ) | throws IOException [static] |
Decompresses the specified zipfile. If the file is a compressed directory, the whole subdirectory structure is created as a subdirectory with the name if the zip file minus the .zip extension from destination. All intermittent directories are also created. If destination is null then the System Property "java.io.tmpdir" is used as destination for the uncompressed file(s).
| f | The file to unzip | |
| destination | 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. |
| IOException |
| static URL URLFromFile | ( | File | file | ) | [static] |
Create an URL for a given file.
| file | name of the file |
| static URL URLFromPath | ( | String | fileName | ) | [static] |
Create an URL for a given path.
| fileName | path of the file |
| static void writeInputStreamToFile | ( | InputStream | stream, | |
| File | file | |||
| ) | throws IOException [static] |
Writes the contents of an InputStream to a specified file.
| file | to write to | |
| stream | to pull data from |
| static void writeInputStreamToFile | ( | File | f, | |
| InputStream | is | |||
| ) | throws IOException [static] |
| static void writeInputStreamToGZippedFile | ( | InputStream | stream, | |
| File | file | |||
| ) | throws IOException [static] |
| static void writeInputStreamToOutputStream | ( | InputStream | in, | |
| boolean | closeInputStream, | |||
| OutputStream | out, | |||
| boolean | closeOutputStream | |||
| ) | throws IOException [static] |
Copies the contents of the input stream to the given output stream.
| in | the input stream to copy from | |
| closeInputStream | if true, the input stream will be closed | |
| out | the output stream to copy to | |
| closeOutputStream | if true, the output stream will be closed |
| IOException | if there is any failure |
| static void writeInputStreamToOutputStream | ( | InputStream | in, | |
| OutputStream | out | |||
| ) | throws IOException [static] |
Copies the contents of the input stream to the given output stream. Both streams are guaranteed to be closed by the end of this method.
| in | the input stream to copy from | |
| out | the output stream to copy to |
| IOException | if there is any failure |
| static File writeInputStreamToTempFile | ( | InputStream | stream, | |
| String | prefix, | |||
| String | suffix | |||
| ) | throws IOException [static] |
Writes the contents of an InputStream to a temporary file.
| stream | to pull data from | |
| prefix | the filename prefix of the temp file | |
| suffix | the filename suffix of the temp file |
| static File writeInputStreamToTempFile | ( | InputStream | stream | ) | throws IOException [static] |
Writes the contents of an InputStream to a temporary file.
| stream | to pull data from |
| static void writeUrlToTempFile | ( | URL | url, | |
| File | file | |||
| ) | throws IOException [static] |
Copies the contents of the given URL to a file.
| url | the URL to copy from | |
| file | the File to write to |
| IOException | if the copy fails |
| static void writeUrlToTempFile | ( | String | url, | |
| File | file | |||
| ) | throws IOException [static] |
Copies the contents of the given URL to a file.
| url | the URL to copy from | |
| file | the File to write to |
| IOException | if the copy fails |
| static File writeUrlToTempFile | ( | URL | url, | |
| String | prefix, | |||
| String | suffix | |||
| ) | throws IOException [static] |
Copies the contents of the given URL to a temporary file.
| url | the URL to copy from | |
| prefix | the temporary file prefix | |
| suffix | the temporary file suffix (if null, the extension from the URL is used) |
| IOException | if the copy fails |
| static File writeUrlToTempFile | ( | String | url, | |
| String | prefix, | |||
| String | suffix | |||
| ) | throws IOException [static] |
Copies the contents of the given URL to a temporary file.
| url | the URL to copy from | |
| prefix | the temporary file prefix | |
| suffix | the temporary file suffix (if null, the extension from the URL is used) |
| IOException | if the copy fails |
| static File zipFile | ( | File | f, | |
| boolean | absolutePaths, | |||
| boolean | deleteOriginal, | |||
| boolean | forceDelete, | |||
| int | level | |||
| ) | throws IOException [static] |
| static File zipFile | ( | File | f, | |
| boolean | absolutePaths, | |||
| boolean | deleteOriginal, | |||
| boolean | forceDelete | |||
| ) | throws IOException [static] |
zips a given File.
| f | the file to zip, either a file or a directory | |
| absolutePaths | if true then the files are added with absolute paths | |
| deleteOriginal | if true then the original file is deleted | |
| forceDelete | if true then the original is deleted even if the file is read only |
1.5.8