public class FileUtilities extends Object
| Constructor and Description |
|---|
FileUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addFileToJarOutputStream(File source,
StringBuilder rootPath,
JarOutputStream target)
Adds a file entry to a JarOutputStream.
|
static void |
createJarFile(File outputFile,
File... files)
Creates a JAR file with the given files as content.
|
static InputStream |
findResource(String name)
Tries to find a resource by the given name.
|
static BufferedInputStream |
getInputStreamFromFile(File file)
Returns an
InputStream for file. |
static BufferedOutputStream |
getOutputStreamToFile(File file)
Returns an
OutputStream for file. |
static BufferedReader |
getReaderFromFile(File file)
Returns a reader from the file file where the file may be a
regular file or gzipped.
|
static BufferedWriter |
getWriterToFile(File file)
Returns a writer to the file file where the destination file may
will be gzipped if file has the extension .gz or .gzip.
|
public static BufferedInputStream getInputStreamFromFile(File file) throws IOException
InputStream for file. Automatically wraps in
an BufferedInputStream and also in an GZIPInputStream if
the file name ends with .gz or .gzip.file - The file to read.IOException - If there is an error during reading.public static BufferedOutputStream getOutputStreamToFile(File file) throws IOException
OutputStream for file. Automatically wraps in
an BufferedOutputStream and also in an GZIPOutputStream
if the file name ends with .gz or .gzip.file - The file to write.IOException - If there is an error during stream creation.public static BufferedReader getReaderFromFile(File file) throws IOException
file - The file to read.IOException - If opening the file fails.public static BufferedWriter getWriterToFile(File file) throws IOException
file - The file to write.IOException - If opening the file fails.public static void createJarFile(File outputFile, File... files) throws IOException
outputFile - The destination where the JAR file should be written.files - The files to be included into the JAR file.IOException - If writing the JAR file fails.public static void addFileToJarOutputStream(File source, StringBuilder rootPath, JarOutputStream target) throws IOException
source - The file that should be added into the JAR.rootPath - target - The JAR file to add source to.IOException - If adding the file fails.public static InputStream findResource(String name) throws IOException
name - The resource name to find.IOException - If reading the resource fails.Copyright © 2019 JULIE Lab, Germany. All rights reserved.