| Modifier and Type | Method and Description |
|---|---|
static void |
closeQuietly(Closeable closeable)
Closes a closeable resource, catching its
IOException. |
static String |
getFileContents(File file)
Reads the contents of a text file.
|
static String |
getFileContents(File file,
String charset)
Reads the contents of a text file.
|
static byte[] |
toByteArray(InputStream in)
Reads all the bytes from an input stream.
|
static byte[] |
toByteArray(InputStream in,
boolean close)
Reads all the bytes from an input stream.
|
static Reader |
utf8Reader(File file)
Creates a reader whose character encoding is set to "UTF-8".
|
static Reader |
utf8Reader(InputStream in)
Creates a reader whose character encoding is set to "UTF-8".
|
static Writer |
utf8Writer(File file)
Creates a writer whose character encoding is set to "UTF-8".
|
static Writer |
utf8Writer(File file,
boolean append)
Creates a writer whose character encoding is set to "UTF-8".
|
static Writer |
utf8Writer(OutputStream out)
Creates a writer whose character encoding is set to "UTF-8".
|
public static byte[] toByteArray(InputStream in) throws IOException
in - the input streamIOException - if there's a problem reading from the input streampublic static byte[] toByteArray(InputStream in, boolean close) throws IOException
in - the input streamclose - true to close the input stream when done, false not toIOException - if there's a problem reading from the input streampublic static String getFileContents(File file) throws IOException
file - the file to readIOException - if there's a problem reading the filepublic static String getFileContents(File file, String charset) throws IOException
file - the file to readcharset - the character encoding of the fileIOException - if there's a problem reading the filepublic static void closeQuietly(Closeable closeable)
IOException.closeable - the resource to close (can be null)public static Writer utf8Writer(OutputStream out)
out - the output stream to write topublic static Writer utf8Writer(File file) throws FileNotFoundException
file - the file to write toFileNotFoundException - if the file cannot be written topublic static Writer utf8Writer(File file, boolean append) throws FileNotFoundException
file - the file to write toappend - true to append to the end of the file, false to overwrite
itFileNotFoundException - if the file cannot be written topublic static Reader utf8Reader(InputStream in)
in - the input stream to read frompublic static Reader utf8Reader(File file) throws FileNotFoundException
file - the file to read fromFileNotFoundException - if the file can't be readCopyright © 2013-2015 Michael Angstadt. All Rights Reserved.