Class FileUtil
java.lang.Object
org.zeroturnaround.javarebel.integration.util.FileUtil
Helper methods for managing operations with the file system..
- Author:
- Rein Raudjärv
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanWriteToDir(File dir) static voidcopyAndClose(InputStream in, File outputFile) Copies the given stream to a file.static voidCopies the given file to a new location.static voidforceDelete(File file) Deletes the given file or directory.static byte[]static StringgetExtension(File file) Returns the extension of a given file ornullif the file has no extension.static Collection<File>getUniqueParentDirs(Collection<File> files) static URI
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
copyFile
Copies the given file to a new location.If the destination file already exists it will be overwritten.
- Parameters:
srcFile- source file (notnull, must exist).destFile- destination file (notnull, parent directory must exist).- Throws:
IOException
-
copyAndClose
Copies the given stream to a file.If the destination file already exists it will be overwritten.
- Parameters:
in- source stream (notnull).outputFile- destination file (notnull, parent directory must exist).- Throws:
IOException
-
forceDelete
Deletes the given file or directory. Throws an IOException in case of any error.- Throws:
IOException
-
getExtension
Returns the extension of a given file ornullif the file has no extension.- Parameters:
file- input file (notnull).
-
canWriteToDir
-
getBytes
-
getUniqueParentDirs
- Parameters:
files- Collection of files- Returns:
- files containing only parent directories. For example if there are [C:\weblogic\x\y, C:\weblogic\, C:\tomcat], then result is [C:\weblogic\, C:\tomcat], because C:\weblogic\x\y is a subdirectory of C:\weblogic
-
toURI
-