|
DRAFT-b102 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Inputs
public final class Inputs extends Object
This class consists exclusively of static methods that operate on input sources.
The methods to read lines of text defined by this class recognize the following as Unicode line terminators:
\u000D followed by \u000A,
CARRIAGE RETURN followed by LINE FEED \u000A, LINE FEED \u000D, CARRIAGE RETURN \u2028, LINE SEPARATOR \u2029, PARAGRAPH SEPARATOR \u0085, NEXT LINE (NEL)
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
readAllBytes(FileRef source)
Read all bytes from the specified file. |
static byte[] |
readAllBytes(InputStream source)
Read all bytes from the specified input stream. |
static List<String> |
readAllLines(FileRef source)
Read all lines from the specified file. |
static List<String> |
readAllLines(FileRef source,
String csn)
Read all lines from the specified file. |
static List<String> |
readAllLines(InputStream source)
Read all lines from the specified input stream. |
static List<String> |
readAllLines(InputStream source,
String csn)
Read all lines from the specified input stream. |
static List<String> |
readAllLines(Readable source)
Read all lines from the from the specified source. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static byte[] readAllBytes(FileRef source)
throws IOException
Usage Example: Suppose we want to read all bytes from a file, represented by a java.io.File:
File f = ... byte[] content = Inputs.readAllBytes(f.toPath());
source - the data sourceIOException - if an I/O error occursOutOfMemoryError - if the required array size is too large
public static byte[] readAllBytes(InputStream source)
throws IOException
On return, the input stream will be at end of stream.
source - the data sourceIOException - if an I/O error occursOutOfMemoryError - if the required array size is too large
public static List<String> readAllLines(FileRef source,
String csn)
throws IOException
Charset. When all lines have
been read, or an I/O error occurs, then the file is closed.
source - the data sourcecsn - the name of the charset to be usedIllegalArgumentException - if the charset name is illegal or not available in this instance
of the Java virtual machineCharacterCodingException - if the file contains a malformed or unmappable byte sequence for
the charsetIOException - if an I/O error occurs
public static List<String> readAllLines(FileRef source)
throws IOException
source - the data sourceCharacterCodingException - if the file contains a malformed or unmappable byte sequence for
the default charsetIOException - if an I/O error occurs
public static List<String> readAllLines(InputStream source,
String csn)
throws IOException
Charset.
On return, the input stream will be at end of stream.
source - the input stream to read fromcsn - the name of the charset to be usedIllegalArgumentException - if the charset name is illegal or not available in this instance
of the Java virtual machineCharacterCodingException - if the input contains a malformed or unmappable byte sequence
for the charsetIOException - if an I/O error occurs
public static List<String> readAllLines(InputStream source)
throws IOException
On return, the input stream will be at end of stream.
source - the input stream to read fromCharacterCodingException - if the input contains a malformed or unmappable byte sequence
for the default charsetIOException - if an I/O error occurs
public static List<String> readAllLines(Readable source)
throws IOException
On return, the source will be at its end.
source - The source to read fromIOException - If an I/O error occurs
|
DRAFT-b102 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||