Package oracle.dbtools.plugin.api.io
Interface IOStreams
-
public interface IOStreams
Methods for working withInputStream
,OutputStream
,Readable
, andAppendable
streams.- Author:
- cdivilly
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]
asByteArray(java.io.InputStream is)
buffer the contents of the specified byte stream into abyte[]
array.byte[]
asByteArray(java.lang.CharSequence text)
Convert the specified text into a UTF-8 encodedbyte[]
array.byte[]
asByteArray(java.lang.Readable r)
Buffer the contents of the specifiedReadable
into abyte[]
arraybyte[]
asByteArray(java.nio.channels.ReadableByteChannel r)
Buffer the contents of the specifiedReadableByteChannel
into abyte[]
arrayjava.nio.channels.SeekableByteChannel
asByteChannel(byte[] bytes)
Adapt the specified byte array to a read only instance ofSeekableByteChannel
.java.io.InputStream
asInputStream(byte[] bytes)
Adapt the specified byte array to an instance ofInputStream
.java.io.InputStream
asInputStream(java.lang.CharSequence text)
Convert aCharSequence
into anInputStream
instancejava.lang.String
asString(java.io.InputStream is)
Buffer the contents of the specified byte stream into aString
.java.lang.String
asString(java.lang.Readable r)
Buffer the contents of the specified character stream into aString
.long
copy(java.io.InputStream is, java.io.OutputStream os)
Copy the contents of aInputStream
to anOutputStream
long
copy(java.lang.Readable source, java.lang.Appendable destination)
Copy the contents of aReadable
(input character stream) to anAppendable
(output character stream)long
copy(java.nio.channels.ReadableByteChannel source, java.nio.channels.WritableByteChannel destination)
Copy the contents of aReadableByteChannel
(input byte stream) to aWritableByteChannel
(output byte stream)java.io.InputStream
emptyStream()
Return an InputStream containing zero bytesboolean
isEmptyStream(java.io.InputStream stream)
Checks if the specifiedInputStream
is the empty stream instance provided byemptyStream()
.java.io.OutputStream
nullStream()
Return anOutputStream
that swallows all output silentlyjava.io.InputStream
uncloseable(java.io.InputStream in)
Wrapper an InputStream so it cannot be closed.
-
-
-
Method Detail
-
copy
long copy(java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException
Copy the contents of aInputStream
to anOutputStream
- Parameters:
is
- The stream containing the contentos
- The stream to write the content to- Returns:
- The number of bytes copied
- Throws:
java.io.IOException
- if an error occurs while reading/writing either stream
-
copy
long copy(java.lang.Readable source, java.lang.Appendable destination) throws java.io.IOException
Copy the contents of aReadable
(input character stream) to anAppendable
(output character stream)- Parameters:
source
- The stream containing the contentdestination
- The stream to write the content to- Returns:
- The number of characters copied
- Throws:
java.io.IOException
- if an error occurs while reading/writing either stream
-
copy
long copy(java.nio.channels.ReadableByteChannel source, java.nio.channels.WritableByteChannel destination) throws java.io.IOException
Copy the contents of aReadableByteChannel
(input byte stream) to aWritableByteChannel
(output byte stream)- Parameters:
source
- The stream containing the contentdestination
- The stream to write the content to- Returns:
- The number of bytes copied
- Throws:
java.io.IOException
- if an error occurs while reading/writing either stream
-
emptyStream
java.io.InputStream emptyStream()
Return an InputStream containing zero bytes- Returns:
- an empty stream
-
nullStream
java.io.OutputStream nullStream()
Return anOutputStream
that swallows all output silently- Returns:
- A null output stream
-
uncloseable
java.io.InputStream uncloseable(java.io.InputStream in)
Wrapper an InputStream so it cannot be closed.- Parameters:
in
- InputStream instance- Returns:
- InputStream instance that cannot be closed.
-
isEmptyStream
boolean isEmptyStream(java.io.InputStream stream)
Checks if the specifiedInputStream
is the empty stream instance provided byemptyStream()
.- Parameters:
stream
- The stream to be tested- Returns:
- true if the specified
InputStream
is the same instance, false otherwise.
-
asString
java.lang.String asString(java.io.InputStream is) throws java.io.IOException
Buffer the contents of the specified byte stream into aString
. The contents of the byte stream must be encoded inUTF-8
.- Parameters:
is
- The byte stream- Returns:
- The buffered stream as a
String
- Throws:
java.io.IOException
- if an error occurs while reading the stream
-
asString
java.lang.String asString(java.lang.Readable r) throws java.io.IOException
Buffer the contents of the specified character stream into aString
.- Parameters:
r
- The character stream- Returns:
- The buffered stream as a
String
- Throws:
java.io.IOException
- if an error occurs while reading the stream
-
asInputStream
java.io.InputStream asInputStream(java.lang.CharSequence text) throws java.io.IOException
Convert aCharSequence
into anInputStream
instance- Parameters:
text
- The text to be transformed into anInputStream
- Returns:
InputStream
instance- Throws:
java.io.IOException
- if an error occurs while reading the stream
-
asInputStream
java.io.InputStream asInputStream(byte[] bytes)
Adapt the specified byte array to an instance ofInputStream
.- Parameters:
bytes
- The bytes to be exposed as a stream- Returns:
- The
InputStream
instance.
-
asByteChannel
java.nio.channels.SeekableByteChannel asByteChannel(byte[] bytes)
Adapt the specified byte array to a read only instance ofSeekableByteChannel
. Note that theSeekableByteChannel.write(java.nio.ByteBuffer)
andSeekableByteChannel.truncate(long)
methods of the returned instance will always throwNonWritableChannelException
. The returned instance is not thread safe, theSeekableByteChannel.position()
state is not multi-thread safe.- Parameters:
bytes
- The bytes to be exposed as a byte channel- Returns:
- read only
SeekableByteChannel
instance
-
asByteArray
byte[] asByteArray(java.io.InputStream is) throws java.io.IOException
buffer the contents of the specified byte stream into abyte[]
array.- Parameters:
is
- The byte stream- Returns:
- byte[] buffer containing the entire contents of the stream
- Throws:
java.io.IOException
- if an error occurs while reading the stream
-
asByteArray
byte[] asByteArray(java.lang.Readable r) throws java.io.IOException
Buffer the contents of the specifiedReadable
into abyte[]
array- Parameters:
r
- The character stream- Returns:
- byte[] buffer containing the entire contents of the stream
- Throws:
java.io.IOException
- if an error occurs while reading the stream
-
asByteArray
byte[] asByteArray(java.lang.CharSequence text) throws java.io.IOException
Convert the specified text into a UTF-8 encodedbyte[]
array.- Parameters:
text
- The text to be converted- Returns:
- byte[] buffer containing the UTF-8 representation of the text
- Throws:
java.io.IOException
- if an error occurs while reading the stream
-
asByteArray
byte[] asByteArray(java.nio.channels.ReadableByteChannel r) throws java.io.IOException
Buffer the contents of the specifiedReadableByteChannel
into abyte[]
array- Parameters:
r
- The byte channel- Returns:
- byte[] buffer containing the entire contents of the stream
- Throws:
java.io.IOException
- if an error occurs while reading the stream
-
-