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 writing to
the specified file. |
static java.io.DataInputStream |
dataInputStream(java.io.File file)
Returns a buffered
java.io.DataInputStream reading from the
specified file. |
static java.io.DataOutputStream |
dataOutputStream(java.io.File file)
Returns a buffered
java.io.DataOutputStream writing to
the specified file. |
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 a non-buffered
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.DataInputStream dataInputStream(java.io.File file)
java.io.DataInputStream
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.DataInputStream
reading from the
specified filejava.lang.NullPointerException
- if file == null
public static java.io.DataOutputStream dataOutputStream(java.io.File file)
java.io.DataOutputStream
writing to
the specified file. Any existing file corresponding to the
File
object will be deleted. If the file cannot be opened,
an error message will be printed and the java interpreter will exit.file
- a filejava.io.DataOutputStream
writing to
the specified filejava.lang.NullPointerException
- if file == null
public 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. Any existing file corresponding
to the specified file will be deleted. If the file
cannot be opened, an error message will be printed and the
java interpreter will exit.file
- a filejava.io.PrintWriter
writing to the specified filejava.lang.NullPointerException
- if file == null
public static java.io.PrintWriter bgzipPrintWriter(java.io.File file)
java.io.PrintWriter
writing to
the specified file. The resulting file will be compressed using
the BGZIP compression algorithm. Any existing file corresponding
to the specified file will be deleted. If the file
cannot be opened, an error message will be printed and the
java interpreter will exit.file
- a filejava.io.PrintWriter
writing to
the specified filejava.lang.NullPointerException
- if file == null
public static java.io.PrintWriter printWriter(java.io.File file)
java.io.PrintWriter
writing to
the specified file. Any existing file corresponding
to the specified filename will be deleted. If the file
cannot be opened, an error message will be printed and the
java interpreter will exit.file
- a filejava.io.PrintWriter
writing to
the specified filejava.lang.NullPointerException
- if file == null
public static java.io.PrintWriter printWriter(java.io.File file, boolean append)
java.io.PrintWriter
writing to
the specified file. If append == false
any existing file corresponding to the specified file will be deleted.
If the file cannot be opened, an error message will be printed and the
java interpreter will exit.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 == null
public static java.io.PrintWriter nonBufferedPrintWriter(java.io.File file, boolean append)
java.io.PrintWriter
writing to
the specified file.
If append == false
any existing file corresponding
to the specified file will be deleted. If the file cannot be opened,
an error message will be printed and the java interpreter will exit.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 == null
public 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