public class IOUtils extends Object
| Constructor and Description |
|---|
IOUtils() |
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
readLines(InputStream input)
Deprecated.
2.5 use
readLines(InputStream, Charset) instead |
static List<String> |
readLines(InputStream input,
Charset encoding)
Gets the contents of an
InputStream as a list of Strings,
one entry per line, using the specified character encoding. |
static List<String> |
readLines(InputStream input,
String encoding)
Gets the contents of an
InputStream as a list of Strings,
one entry per line, using the specified character encoding. |
static List<String> |
readLines(Reader input)
Gets the contents of a
Reader as a list of Strings,
one entry per line. |
static BufferedReader |
toBufferedReader(Reader reader)
Returns the given reader if it is a
BufferedReader, otherwise creates a BufferedReader from the given
reader. |
static Charset |
toCharset(Charset charset)
Returns the given Charset or the default Charset if the given Charset is null.
|
static Charset |
toCharset(String charset)
Returns a Charset for the named charset.
|
@Deprecated public static List<String> readLines(InputStream input) throws IOException
readLines(InputStream, Charset) insteadInputStream as a list of Strings,
one entry per line, using the default character encoding of the platform.
This method buffers the input internally, so there is no need to use a
BufferedInputStream.
input - the InputStream to read from, not nullNullPointerException - if the input is nullIOException - if an I/O error occurspublic static List<String> readLines(InputStream input, Charset encoding) throws IOException
InputStream as a list of Strings,
one entry per line, using the specified character encoding.
This method buffers the input internally, so there is no need to use a
BufferedInputStream.
input - the InputStream to read from, not nullencoding - the encoding to use, null means platform defaultNullPointerException - if the input is nullIOException - if an I/O error occurspublic static List<String> readLines(InputStream input, String encoding) throws IOException
InputStream as a list of Strings,
one entry per line, using the specified character encoding.
Character encoding names can be found at IANA.
This method buffers the input internally, so there is no need to use a
BufferedInputStream.
input - the InputStream to read from, not nullencoding - the encoding to use, null means platform defaultNullPointerException - if the input is nullIOException - if an I/O error occursUnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the
encoding is not supported.public static List<String> readLines(Reader input) throws IOException
Reader as a list of Strings,
one entry per line.
This method buffers the input internally, so there is no need to use a
BufferedReader.
input - the Reader to read from, not nullNullPointerException - if the input is nullIOException - if an I/O error occurspublic static BufferedReader toBufferedReader(Reader reader)
BufferedReader, otherwise creates a BufferedReader from the given
reader.reader - the reader to wrap or return (not null)BufferedReader for the given readerNullPointerException - if the input parameter is nullpublic static Charset toCharset(Charset charset)
charset - A charset or null.public static Charset toCharset(String charset)
charset - The name of the requested charset, may be null.UnsupportedCharsetException - If the named charset is unavailableCopyright © 2018. All rights reserved.