public interface IOStreams
| Modifier and Type | Method and Description |
|---|---|
byte[] |
asByteArray(CharSequence text)
Convert the specified text into a UTF-8 encoded
byte[] array. |
byte[] |
asByteArray(InputStream is)
buffer the contents of the specified byte stream into a
byte[] array. |
byte[] |
asByteArray(Readable r)
Buffer the contents of the specified
Readable into a byte[] array |
byte[] |
asByteArray(ReadableByteChannel r)
Buffer the contents of the specified
ReadableByteChannel into a byte[] array |
SeekableByteChannel |
asByteChannel(byte[] bytes)
Adapt the specified byte array to a read only instance of
SeekableByteChannel. |
InputStream |
asInputStream(byte[] bytes)
Adapt the specified byte array to an instance of
InputStream. |
InputStream |
asInputStream(CharSequence text)
Convert a
CharSequence into an InputStream instance |
String |
asString(InputStream is)
Buffer the contents of the specified byte stream into a
String. |
String |
asString(Readable r)
Buffer the contents of the specified character stream into a
String . |
long |
copy(InputStream is, OutputStream os)
Copy the contents of a
InputStream to an OutputStream |
long |
copy(Readable source, Appendable destination)
Copy the contents of a
Readable (input character stream) to an Appendable (output character stream) |
long |
copy(ReadableByteChannel source, WritableByteChannel destination)
Copy the contents of a
ReadableByteChannel (input byte stream) to a WritableByteChannel (output byte stream) |
InputStream |
emptyStream()
Return an InputStream containing zero bytes
|
boolean |
isEmptyStream(InputStream stream)
Checks if the specified
InputStream is the empty stream instance provided by emptyStream(). |
OutputStream |
nullStream()
Return an
OutputStream that swallows all output silently |
InputStream |
uncloseable(InputStream in)
Wrapper an InputStream so it cannot be closed.
|
long copy(InputStream is, OutputStream os) throws IOException
InputStream to an OutputStreamis - The stream containing the contentos - The stream to write the content toIOException - if an error occurs while reading/writing either streamlong copy(Readable source, Appendable destination) throws IOException
Readable (input character stream) to an Appendable (output character stream)source - The stream containing the contentdestination - The stream to write the content toIOException - if an error occurs while reading/writing either streamlong copy(ReadableByteChannel source, WritableByteChannel destination) throws IOException
ReadableByteChannel (input byte stream) to a WritableByteChannel (output byte stream)source - The stream containing the contentdestination - The stream to write the content toIOException - if an error occurs while reading/writing either streamInputStream emptyStream()
OutputStream nullStream()
OutputStream that swallows all output silentlyInputStream uncloseable(InputStream in)
in - InputStream instanceboolean isEmptyStream(InputStream stream)
InputStream is the empty stream instance provided by emptyStream().stream - The stream to be testedInputStream is the same instance, false otherwise.String asString(InputStream is) throws IOException
String. The contents of the byte stream must be encoded in UTF-8.is - The byte streamStringIOException - if an error occurs while reading the streamString asString(Readable r) throws IOException
String .r - The character streamStringIOException - if an error occurs while reading the streamInputStream asInputStream(CharSequence text) throws IOException
CharSequence into an InputStream instancetext - The text to be transformed into an InputStreamInputStream instanceIOException - if an error occurs while reading the streamInputStream asInputStream(byte[] bytes)
InputStream.bytes - The bytes to be exposed as a streamInputStream instance.SeekableByteChannel asByteChannel(byte[] bytes)
SeekableByteChannel. Note that the SeekableByteChannel.write(java.nio.ByteBuffer) and SeekableByteChannel.truncate(long) methods of the returned instance will always throw NonWritableChannelException. The returned instance is not thread safe, the SeekableByteChannel.position() state is not multi-thread safe.bytes - The bytes to be exposed as a byte channelSeekableByteChannel instancebyte[] asByteArray(InputStream is) throws IOException
byte[] array.is - The byte streamIOException - if an error occurs while reading the streambyte[] asByteArray(Readable r) throws IOException
Readable into a byte[] arrayr - The character streamIOException - if an error occurs while reading the streambyte[] asByteArray(CharSequence text) throws IOException
byte[] array.text - The text to be convertedIOException - if an error occurs while reading the streambyte[] asByteArray(ReadableByteChannel r) throws IOException
ReadableByteChannel into a byte[] arrayr - The byte channelIOException - if an error occurs while reading the stream