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() . |
InputStream |
uncloseable(InputStream in)
Wrapper an InputStream so it cannot be closed.
|
long copy(InputStream is, OutputStream os) throws IOException
InputStream
to an OutputStream
is
- The stream containing the contentos
- The stream to write the content toIOException
long 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
long 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
InputStream emptyStream()
InputStream 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 streamString
IOException
String asString(Readable r) throws IOException
String
.r
- The character streamString
IOException
InputStream asInputStream(CharSequence text) throws IOException
CharSequence
into an InputStream
instancetext
- The text to be transformed into an InputStream
InputStream
instanceIOException
InputStream 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
- SeekableByteChannel
instancebyte[] asByteArray(InputStream is) throws IOException
byte[]
array.is
- The byte streamIOException
byte[] asByteArray(Readable r) throws IOException
Readable
into a
byte[]
arrayr
- The character streamIOException
byte[] asByteArray(CharSequence text) throws IOException
byte[]
array.text
- The text to be convertedIOException
byte[] asByteArray(ReadableByteChannel r) throws IOException
ReadableByteChannel
into a
byte[]
arrayr
- The byte channelIOException