Package snap.util
Class FileUtils
java.lang.Object
snap.util.FileUtils
Utility methods for file.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
Copies a file from one location to another.static File
copyFileSafe
(File in, File out) Copies a file from one location to another with exception suppression.static boolean
deleteDeep
(File aFile) Deletes a directory.static File
getAppDataDir
(String aName, boolean doCreate) Returns the AppData or Application Support directory file.static byte[]
Returns bytes for a file.static byte[]
getBytesOrThrow
(File aFile) Returns bytes for a file.static File
getDirForSource
(Object aSource, boolean doCreate) Returns a directory for given source (path, url, string path) with option to create if missing.static File
Returns a File object from a source, if one can be divined.static File
Returns the temp directory.static File
getTempFile
(String aName) Creates a file in the temp directory.static File
getUserHomeDir
(String aName, boolean doCreate) Returns a file for named directory in the user's home directory (with option to create).static boolean
Moves a file.static void
Tries to open the given file name with the platform reader.static void
Tries to open the given file name with the platform reader.static void
Unzips the given file into the destination file.static void
writeBytes
(File aFile, byte[] theBytes) Writes the given bytes (within the specified range) to the given file.static void
writeBytesSafely
(File aFile, byte[] theBytes) Writes the given bytes (within the specified range) to the given file, with an option for doing it "safely".
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
getFile
Returns a File object from a source, if one can be divined. -
getDirForSource
Returns a directory for given source (path, url, string path) with option to create if missing. -
openFile
Tries to open the given file name with the platform reader. -
openFile
Tries to open the given file name with the platform reader. -
getBytes
Returns bytes for a file. -
getBytesOrThrow
Returns bytes for a file.- Throws:
IOException
-
writeBytes
Writes the given bytes (within the specified range) to the given file.- Throws:
IOException
-
writeBytesSafely
Writes the given bytes (within the specified range) to the given file, with an option for doing it "safely".- Throws:
IOException
-
getTempDir
Returns the temp directory. -
getTempFile
Creates a file in the temp directory. -
getUserHomeDir
Returns a file for named directory in the user's home directory (with option to create). -
getAppDataDir
Returns the AppData or Application Support directory file. -
copyFile
Copies a file from one location to another.- Throws:
IOException
-
copyFileSafe
Copies a file from one location to another with exception suppression. -
move
Moves a file.- Throws:
IOException
-
deleteDeep
Deletes a directory. -
unzipFile
Unzips the given file into the destination file.- Throws:
IOException
-