|
NIO2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.classpath.icedtea.java.io.Inputs
public final class Inputs
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)
Method Summary | |
---|---|
static void |
closeUnchecked(Closeable source)
Closes the given data source by invoking its close
method. |
static byte[] |
readAllBytes(File source)
Read all bytes from the specified file. |
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(File source)
Read all lines from the specified file. |
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(File 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 void closeUnchecked(Closeable source)
close
method. If the close
method throws an IOException
then it
is silently ignored. If the source is already closed then invoking this
method has no effect.
This method should not be used to close destinations or output streams that may be buffered. An I/O error may occur when flushing buffered data.
source
- The data sourcepublic static byte[] readAllBytes(FileRef source) throws IOException
source
- The data source
IOException
- If an I/O error occurs
OutOfMemoryError
- If the required array size is too largepublic static byte[] readAllBytes(File source) throws IOException
source
- The data source
IOException
- If an I/O error occurs
OutOfMemoryError
- If the required array size is too largepublic static byte[] readAllBytes(InputStream source) throws IOException
Usage Example: Suppose we want to open a connection to a resource identified by a URI, and read all bytes:
URI uri = ... byte[] content = InputOutput.readAllBytes(uri.toURL().openStream());
On return, the input stream will be at end of stream.
source
- The data source
IOException
- If an I/O error occurs
OutOfMemoryError
- If the required array size is too largepublic static List<String> readAllLines(FileRef source, String csn) throws IOException
source
- The data sourcecsn
- The name of the charset to be used
UnsupportedCharsetException
- If no support for the named charset is available
in this instance of the Java virtual machine
MalformedInputException
- If the file contains a byte sequence that is not legal for the
charset
IOException
- If an I/O error occurspublic static List<String> readAllLines(FileRef source) throws IOException
source
- The data source
MalformedInputException
- If the file contains a byte sequence that is not legal for the
default charset
IOException
- If an I/O error occurspublic static List<String> readAllLines(File source, String csn) throws IOException
source
- The data sourcecsn
- The name of the charset to be used
UnsupportedCharsetException
- If no support for the named charset is available
in this instance of the Java virtual machine
MalformedInputException
- If the file contains a byte sequence that is not legal for the
charset
IOException
- If an I/O error occurspublic static List<String> readAllLines(File source) throws IOException
source
- The data source
MalformedInputException
- If the file contains a byte sequence that is not legal for the
default charset
IOException
- If an I/O error occurspublic static List<String> readAllLines(InputStream source, String csn) throws IOException
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 used
UnsupportedCharsetException
- If no support for the named charset is available
in this instance of the Java virtual machine
MalformedInputException
- If a byte sequence that is not legal for the charset is read
from the input
IOException
- If an I/O error occurspublic 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 from
MalformedInputException
- If a byte sequence that is not legal for the default charset is
read from the input
IOException
- If an I/O error occurspublic static List<String> readAllLines(Readable source) throws IOException
On return, the input source will be at end of stream.
source
- The input stream to read from
IOException
- If an I/O error occurs
|
NIO2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2007, 2011, Oracle and/or its affiliates. All rights reserved.