|
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(java.io.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(java.io.InputStream source)
Read all bytes from the specified input stream. |
static java.util.List<java.lang.String> |
readAllLines(File source)
Read all lines from the specified file. |
static java.util.List<java.lang.String> |
readAllLines(FileRef source)
Read all lines from the specified file. |
static java.util.List<java.lang.String> |
readAllLines(FileRef source,
java.lang.String csn)
Read all lines from the specified file. |
static java.util.List<java.lang.String> |
readAllLines(File source,
java.lang.String csn)
Read all lines from the specified file. |
static java.util.List<java.lang.String> |
readAllLines(java.io.InputStream source)
Read all lines from the specified input stream. |
static java.util.List<java.lang.String> |
readAllLines(java.io.InputStream source,
java.lang.String csn)
Read all lines from the specified input stream. |
static java.util.List<java.lang.String> |
readAllLines(java.lang.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(java.io.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 java.io.IOException
source
- The data source
java.io.IOException
- If an I/O error occurs
java.lang.OutOfMemoryError
- If the required array size is too largepublic static byte[] readAllBytes(File source) throws java.io.IOException
source
- The data source
java.io.IOException
- If an I/O error occurs
java.lang.OutOfMemoryError
- If the required array size is too largepublic static byte[] readAllBytes(java.io.InputStream source) throws java.io.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
java.io.IOException
- If an I/O error occurs
java.lang.OutOfMemoryError
- If the required array size is too largepublic static java.util.List<java.lang.String> readAllLines(FileRef source, java.lang.String csn) throws java.io.IOException
source
- The data sourcecsn
- The name of the charset to be used
java.nio.charset.UnsupportedCharsetException
- If no support for the named charset is available
in this instance of the Java virtual machine
java.nio.charset.MalformedInputException
- If the file contains a byte sequence that is not legal for the
charset
java.io.IOException
- If an I/O error occurspublic static java.util.List<java.lang.String> readAllLines(FileRef source) throws java.io.IOException
source
- The data source
java.nio.charset.MalformedInputException
- If the file contains a byte sequence that is not legal for the
default charset
java.io.IOException
- If an I/O error occurspublic static java.util.List<java.lang.String> readAllLines(File source, java.lang.String csn) throws java.io.IOException
source
- The data sourcecsn
- The name of the charset to be used
java.nio.charset.UnsupportedCharsetException
- If no support for the named charset is available
in this instance of the Java virtual machine
java.nio.charset.MalformedInputException
- If the file contains a byte sequence that is not legal for the
charset
java.io.IOException
- If an I/O error occurspublic static java.util.List<java.lang.String> readAllLines(File source) throws java.io.IOException
source
- The data source
java.nio.charset.MalformedInputException
- If the file contains a byte sequence that is not legal for the
default charset
java.io.IOException
- If an I/O error occurspublic static java.util.List<java.lang.String> readAllLines(java.io.InputStream source, java.lang.String csn) throws java.io.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
java.nio.charset.UnsupportedCharsetException
- If no support for the named charset is available
in this instance of the Java virtual machine
java.nio.charset.MalformedInputException
- If a byte sequence that is not legal for the charset is read
from the input
java.io.IOException
- If an I/O error occurspublic static java.util.List<java.lang.String> readAllLines(java.io.InputStream source) throws java.io.IOException
On return, the input stream will be at end of stream.
source
- The input stream to read from
java.nio.charset.MalformedInputException
- If a byte sequence that is not legal for the default charset is
read from the input
java.io.IOException
- If an I/O error occurspublic static java.util.List<java.lang.String> readAllLines(java.lang.Readable source) throws java.io.IOException
On return, the input source will be at end of stream.
source
- The input stream to read from
java.io.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 2010 Sun Microsystems, Inc. All rights reserved. Use is subject to the terms of the GNU General Public License.