public class FileUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String[] |
readFile(File f)
Reads every line from a given text file.
|
static Object |
readGzippedObject(File f)
Reads a serialized object from a file that has been compressed using gzip.
|
static Object |
readObject(File f)
Reads a Serialized object, which may or may not be zipped.
|
static Object |
readUnzippedObject(File f)
Reads a serialized object from a file.
|
static File |
uniqueFile(File dir,
String prefix,
String extension)
Creates a file, making sure that its name is unique.
|
static void |
writeGzippedObject(File f,
Serializable obj)
Writes a serialized version of obj to a given file, compressing it using gzip.
|
static void |
writeObject(File f,
Serializable obj)
Serializes an object to a file, masking out annoying exceptions.
|
public static void writeObject(File f, Serializable obj)
writeGzippedObject(java.io.File, java.io.Serializable)
instead, for that method will compress the serialized file, and it'll still
be reaoable by readObject(java.io.File).f - File to write toobj - Object to serializewriteGzippedObject(java.io.File, java.io.Serializable)public static Object readObject(File f)
f - File to read data frompublic static Object readUnzippedObject(File f)
readObject(java.io.File) instead, because that method will automatically guess
from the extension whether the file is compressed, and call this method if necessary.f - File to read object fromreadObject(java.io.File)public static String[] readFile(File f) throws IOException
f - Input file.f.IOExceptionpublic static File uniqueFile(File dir, String prefix, String extension) throws IOException
dir - Directory to use for the returned fileprefix - Prefix of the file name (before the uniquifying integer)extension - Suffix of the file name (after the uniquifying integer)IOExceptionpublic static void writeGzippedObject(File f, Serializable obj)
f - File to write toobj - Object to serializepublic static Object readGzippedObject(File f)
readObject(java.io.File) instead, because it will automatically guess
from the extension whether the file is compressed, and call this method if necessary.f - Compressed file to read object fromreadObject(java.io.File)Copyright © 2019 JULIE Lab, Germany. All rights reserved.