Package oracle.dbtools.plugin.api.io
Interface IOStreams
-
public interface IOStreamsMethods for working withInputStream,OutputStream,Readable, andAppendablestreams.- 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 specifiedReadableinto abyte[]arraybyte[]asByteArray(java.nio.channels.ReadableByteChannel r)Buffer the contents of the specifiedReadableByteChannelinto abyte[]arrayjava.nio.channels.SeekableByteChannelasByteChannel(byte[] bytes)Adapt the specified byte array to a read only instance ofSeekableByteChannel.java.io.InputStreamasInputStream(byte[] bytes)Adapt the specified byte array to an instance ofInputStream.java.io.InputStreamasInputStream(java.lang.CharSequence text)Convert aCharSequenceinto anInputStreaminstancejava.lang.StringasString(java.io.InputStream is)Buffer the contents of the specified byte stream into aString.java.lang.StringasString(java.lang.Readable r)Buffer the contents of the specified character stream into aString.longcopy(java.io.InputStream is, java.io.OutputStream os)Copy the contents of aInputStreamto anOutputStreamlongcopy(java.lang.Readable source, java.lang.Appendable destination)Copy the contents of aReadable(input character stream) to anAppendable(output character stream)longcopy(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.InputStreamemptyStream()Return an InputStream containing zero bytesbooleanisEmptyStream(java.io.InputStream stream)Checks if the specifiedInputStreamis the empty stream instance provided byemptyStream().java.io.OutputStreamnullStream()Return anOutputStreamthat swallows all output silentlyjava.io.InputStreamuncloseable(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.IOExceptionCopy the contents of aInputStreamto 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.IOExceptionCopy 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.IOExceptionCopy 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 anOutputStreamthat 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 specifiedInputStreamis the empty stream instance provided byemptyStream().- Parameters:
stream- The stream to be tested- Returns:
- true if the specified
InputStreamis the same instance, false otherwise.
-
asString
java.lang.String asString(java.io.InputStream is) throws java.io.IOExceptionBuffer 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.IOExceptionBuffer 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.IOExceptionConvert aCharSequenceinto anInputStreaminstance- Parameters:
text- The text to be transformed into anInputStream- Returns:
InputStreaminstance- 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
InputStreaminstance.
-
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
SeekableByteChannelinstance
-
asByteArray
byte[] asByteArray(java.io.InputStream is) throws java.io.IOExceptionbuffer 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.IOExceptionBuffer the contents of the specifiedReadableinto 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.IOExceptionConvert 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.IOExceptionBuffer the contents of the specifiedReadableByteChannelinto 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
-
-