|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectezvcard.util.IOUtils
public class IOUtils
I/O helper classes.
Method Summary | |
---|---|
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 String |
getFileExtension(File file)
Gets the extension off a file's name. |
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". |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String getFileExtension(File file)
file
- the file
public static byte[] toByteArray(InputStream in) throws IOException
in
- the input stream
IOException
- 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 to
IOException
- if there's a problem reading from the input streampublic static String getFileContents(File file) throws IOException
file
- the file to read
IOException
- 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 file
IOException
- 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 to
public static Writer utf8Writer(File file) throws FileNotFoundException
file
- the file to write to
FileNotFoundException
- 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
it
FileNotFoundException
- if the file cannot be written topublic static Reader utf8Reader(InputStream in)
in
- the input stream to read from
public static Reader utf8Reader(File file) throws FileNotFoundException
file
- the file to read from
FileNotFoundException
- if the file can't be read
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |