public class FileUtil
extends java.lang.Object
FileUtil contains static methods for working with files.| Modifier and Type | Method and Description |
|---|---|
static java.io.PrintWriter |
bgzipPrintWriter(java.io.File file)
Returns a buffered
java.io.PrintWriter that compresses
data using the BGZIP algorithm and writes the compressed data
to the specified file. |
static java.io.PrintWriter |
bgzipPrintWriter(java.io.File file,
boolean append)
Returns a buffered
java.io.PrintWriter that compresses
data using the BGZIP algorithm and writes the compressed data to
the specified file. |
static java.io.FileInputStream |
fileInputStream(java.io.File file)
Returns an unbuffered
java.io.FileInputStream reading from the
specified file. |
static java.io.FileOutputStream |
fileOutputStream(java.io.File file)
Returns an unbuffered
java.io.FileOutputStream. |
static java.io.FileOutputStream |
fileOutputStream(java.io.File file,
boolean append)
Returns an unbuffered
java.io.FileOutputStream. |
static java.io.PrintWriter |
gzipPrintWriter(java.io.File file)
Returns a buffered
java.io.PrintWriter writing to
the specified file. |
static java.io.PrintWriter |
nonBufferedPrintWriter(java.io.File file,
boolean append)
Returns an unbuffered
java.io.PrintWriter writing to
the specified file. |
static java.io.PrintWriter |
printWriter(java.io.File file)
Returns a buffered
java.io.PrintWriter writing to the
specified file. |
static java.io.PrintWriter |
printWriter(java.io.File file,
boolean append)
Returns a buffered
java.io.PrintWriter writing to
the specified file. |
static java.io.PrintWriter |
stdOutPrintWriter()
Returns a
java.io.PrintWriter that writes
to standard out. |
static java.io.File |
tempFile(java.lang.String prefix)
Returns a temporary
File that will be deleted when
the Java virtual machine exits. |
public static java.io.FileInputStream fileInputStream(java.io.File file)
java.io.FileInputStream reading from the
specified file. If the input stream cannot be opened, an error message
will be printed and the java interpreter will exit.file - a filejava.io.FileInputStreamjava.lang.NullPointerException - if file == nullpublic static java.io.FileOutputStream fileOutputStream(java.io.File file)
java.io.FileOutputStream. If the file
cannot be opened for writing, an error message will be printed and the
Java Virtual Machine will exit. If the specified file exists, bytes
written by the returned FileOutputSream will overwrite the
previously existing file.file - a filejava.io.PrintWriterjava.lang.NullPointerException - if file == nullpublic static java.io.FileOutputStream fileOutputStream(java.io.File file,
boolean append)
java.io.FileOutputStream. If the file
cannot be opened for writing, an error message will be printed and the
Java Virtual Machine will exit. If the specified file exists and
append is false, bytes written by the returned
PrintWriter will overwrite the previously existing file.file - a fileappend - true if bytes will be appended to the end of
the filejava.io.PrintWriterjava.lang.NullPointerException - if file == nullpublic static java.io.PrintWriter stdOutPrintWriter()
java.io.PrintWriter that writes
to standard out.java.io.PrintWriter that writes
to standard outpublic static java.io.PrintWriter gzipPrintWriter(java.io.File file)
java.io.PrintWriter writing to
the specified file. The resulting file will be compressed using
the GZIP compression algorithm. If the file cannot be opened, an
error message will be printed and the java interpreter will exit.
If the specified file exists, bytes written by the returned
PrintWriter will overwrite the previously existing file.file - a filejava.io.PrintWriter writing to the specified filejava.lang.NullPointerException - if file == nullpublic static java.io.PrintWriter bgzipPrintWriter(java.io.File file)
java.io.PrintWriter that compresses
data using the BGZIP algorithm and writes the compressed data
to the specified file. The close() method of the returned
PrintWriter will write an empty BGZIP block to the end of the
output stream. If the file cannot be opened for writing, an error
message will be printed and the Java Virtual Machine will exit.
If the specified file exists, bytes written by the returned
PrintWriter will overwrite the previously existing file.file - a filejava.io.PrintWriterjava.lang.NullPointerException - if file == nullpublic static java.io.PrintWriter bgzipPrintWriter(java.io.File file,
boolean append)
java.io.PrintWriter that compresses
data using the BGZIP algorithm and writes the compressed data to
the specified file. The close() method of the returned
PrintWriter will write an empty BGZIP block to the end of the
output stream. If the file cannot be opened for writing, an error
message will be printed and the Java Virtual Machine will exit.
If the specified file exists and append is false, bytes
written by the returned PrintWriter will overwrite the
previously existing file.file - a fileappend - true if bytes will be appended to the end of
the filejava.io.PrintWriterjava.lang.NullPointerException - if file == nullpublic static java.io.PrintWriter printWriter(java.io.File file)
java.io.PrintWriter writing to the
specified file. If the file cannot be opened, an error message
will be printed and the Java Virtual Machine will exit. If the specified
file exists, bytes written by the returned PrintWriter will
overwrite the previously existing file.file - a filejava.io.PrintWriter writing to
the specified filejava.lang.NullPointerException - if file == nullpublic static java.io.PrintWriter printWriter(java.io.File file,
boolean append)
java.io.PrintWriter writing to
the specified file. If the file cannot be opened, an error message will
be printed and the Java Virtual Machine will exit. If the specified
file exists and append is false, bytes written by the
returned PrintWriter will overwrite the previously existing file.file - a fileappend - true if the data will be appended
to the end of any existing filejava.io.PrintWriter writing to
the specified filejava.lang.NullPointerException - if file == nullpublic static java.io.PrintWriter nonBufferedPrintWriter(java.io.File file,
boolean append)
java.io.PrintWriter writing to
the specified file. If the file cannot be opened, an error message will
be printed and the Java Virtual Machine will exit. If the specified
file exists and append is false, bytes written by the
returned PrintWriter will overwrite the previously existing file.file - a fileappend - true if the data will be appended
to the end of any existing filejava.io.PrintWriter writing to
the specified filejava.lang.NullPointerException - if file == nullpublic static java.io.File tempFile(java.lang.String prefix)
File that will be deleted when
the Java virtual machine exits.prefix - the filename prefix.File a new empty file.java.lang.IllegalArgumentException - if prefix contains fewer than
three characters