Package org.eclipse.mat.util
Class FileUtils
java.lang.Object
org.eclipse.mat.util.FileUtils
File utilities for things like copying icon files.
-
Method Summary
Modifier and TypeMethodDescriptionstatic final voidcopy(InputStream in, OutputStream out) Basic stream copy, the streams are already open and stay open afterward.static FilecreateTempDirectory(String prefix, File parent) Create a temporary directory which should be deleted on application close.static StringtoFilename(String name, String extension) static StringtoFilename(String prefix, String suffix, String extension) Build a file name.static voidUnzip the specified zip file into a directory of the same name as the zip file minus the suffix within the same parent directory.static voidUnzip the specified zip file into the specified destination.static voidwriteToFile(File file, String message, boolean append, boolean addNewline) Append a string to a file.
-
Method Details
-
copy
Basic stream copy, the streams are already open and stay open afterward.- Parameters:
in- input streamout- output stream- Throws:
IOException- if there was a problem with the copy
-
createTempDirectory
Create a temporary directory which should be deleted on application close.- Parameters:
prefix- a prefix for the new directory nameparent- a directory to put the new directory into- Returns:
- the temporary directory, to be deleted on shutdown
- Throws:
IOException- if something goes wrong
-
toFilename
-
toFilename
Build a file name. Convert non-letters or digits to underscore.- Parameters:
prefix- the prefix of the filesuffix- the suffixextension- the file extension- Returns:
- the combined file name
-
unzipFile
Unzip the specified zip file into a directory of the same name as the zip file minus the suffix within the same parent directory.- Parameters:
file- .zip file- Throws:
IOException- Since:
- 1.12
-
unzipFile
Unzip the specified zip file into the specified destination.- Parameters:
file- .zip filedestinationDirectory- Destination directory- Throws:
IOException- Since:
- 1.12
-
writeToFile
public static void writeToFile(File file, String message, boolean append, boolean addNewline) throws IOException Append a string to a file.- Parameters:
file- The file to append to.message- The string to append.addNewline- Whether to add a newline after the message.- Throws:
IOException- Errors writing to the file.- Since:
- 1.17
-