Package oracle.dbtools.plugin.api.io
Interface IOStreams
public interface IOStreams
- Author:
- cdivilly
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]asByteArray<wbr>(InputStream is)buffer the contents of the specified byte stream into abyte[]array.byte[]asByteArray<wbr>(CharSequence text)Convert the specified text into a UTF-8 encodedbyte[]array.byte[]asByteArray<wbr>(Readable r)Buffer the contents of the specifiedReadableinto abyte[]arraybyte[]asByteArray<wbr>(ReadableByteChannel r)Buffer the contents of the specifiedReadableByteChannelinto abyte[]arrayasByteChannel<wbr>(byte[] bytes)Adapt the specified byte array to a read only instance ofSeekableByteChannel.asInputStream<wbr>(byte[] bytes)Adapt the specified byte array to an instance ofInputStream.asInputStream<wbr>(CharSequence text)Convert aCharSequenceinto anInputStreaminstanceasString<wbr>(InputStream is)Buffer the contents of the specified byte stream into aString.Buffer the contents of the specified character stream into aString.asStringReadByLine<wbr>(BufferedReader r)Reads the contents of the specified character input stream into aString.longcopy<wbr>(InputStream is, OutputStream os)Copy the contents of aInputStreamto anOutputStreamlongcopy<wbr>(Readable source, Appendable destination)Copy the contents of aReadable(input character stream) to anAppendable(output character stream)longcopy<wbr>(ReadableByteChannel source, WritableByteChannel destination)Copy the contents of aReadableByteChannel(input byte stream) to aWritableByteChannel(output byte stream)Return an InputStream containing zero bytesbooleanisEmptyStream<wbr>(InputStream stream)Checks if the specifiedInputStreamis the empty stream instance provided byemptyStream().Return anOutputStreamthat swallows all output silentlyuncloseable<wbr>(InputStream in)Wrapper an InputStream so it cannot be closed.
-
Method Details
-
copy
Copy 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:
IOException- if an error occurs while reading/writing either stream
-
copy
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:
IOException- if an error occurs while reading/writing either stream
-
copy
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:
IOException- if an error occurs while reading/writing either stream
-
emptyStream
InputStream emptyStream()Return an InputStream containing zero bytes- Returns:
- an empty stream
-
nullStream
OutputStream nullStream()Return anOutputStreamthat swallows all output silently- Returns:
- A null output stream
-
uncloseable
Wrapper an InputStream so it cannot be closed.- Parameters:
in- InputStream instance- Returns:
- InputStream instance that cannot be closed.
-
isEmptyStream
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
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:
IOException- if an error occurs while reading the stream
-
asString
Buffer the contents of the specified character stream into aString.- Parameters:
r- The character stream- Returns:
- The buffered stream as a
String - Throws:
IOException- if an error occurs while reading the stream
-
asStringReadByLine
Reads the contents of the specified character input stream into aString. This method receives a BufferedReader, which is a more efficient way to read characters from the stream line by line. It is advisable to wrap a BufferedReader around any Reader whose read() operations may be costly.- Parameters:
r- The character stream- Returns:
- The buffered stream as a
String - Throws:
IOException- if an error occurs while reading the stream
-
asInputStream
Convert aCharSequenceinto anInputStreaminstance- Parameters:
text- The text to be transformed into anInputStream- Returns:
InputStreaminstance- Throws:
IOException- if an error occurs while reading the stream
-
asInputStream
Adapt the specified byte array to an instance ofInputStream.- Parameters:
bytes- The bytes to be exposed as a stream- Returns:
- The
InputStreaminstance.
-
asByteChannel
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
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:
IOException- if an error occurs while reading the stream
-
asByteArray
Buffer the contents of the specifiedReadableinto abyte[]array- Parameters:
r- The character stream- Returns:
- byte[] buffer containing the entire contents of the stream
- Throws:
IOException- if an error occurs while reading the stream
-
asByteArray
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:
IOException- if an error occurs while reading the stream
-
asByteArray
Buffer the contents of the specifiedReadableByteChannelinto abyte[]array- Parameters:
r- The byte channel- Returns:
- byte[] buffer containing the entire contents of the stream
- Throws:
IOException- if an error occurs while reading the stream
-