Package oracle.dbtools.plugin.api.io

## Interface IOStreams

-     public interface IOStreams

  Methods for working with `InputStream`, `OutputStream`, `Readable`, and `Appendable` 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 a `byte[]` array.
    `byte[]` | `asByteArray​(java.lang.CharSequence text)` | Convert the specified text into a UTF-8 encoded `byte[]` array.
    `byte[]` | `asByteArray​(java.lang.Readable r)` | Buffer the contents of the specified `Readable` into a `byte[]` array
    `byte[]` | `asByteArray​(java.nio.channels.ReadableByteChannel r)` | Buffer the contents of the specified `ReadableByteChannel` into a `byte[]` array
    `java.nio.channels.SeekableByteChannel` | `asByteChannel​(byte[] bytes)` | Adapt the specified byte array to a read only instance of `SeekableByteChannel`.
    `java.io.InputStream` | `asInputStream​(byte[] bytes)` | Adapt the specified byte array to an instance of `InputStream`.
    `java.io.InputStream` | `asInputStream​(java.lang.CharSequence text)` | Convert a `CharSequence` into an `InputStream` instance
    `java.lang.String` | `asString​(java.io.InputStream is)` | Buffer the contents of the specified byte stream into a `String`.
    `java.lang.String` | `asString​(java.lang.Readable r)` | Buffer the contents of the specified character stream into a `String` .
    `long` | `copy​(java.io.InputStream is, java.io.OutputStream os)` | Copy the contents of a `InputStream` to an `OutputStream`
    `long` | `copy​(java.lang.Readable source, java.lang.Appendable destination)` | Copy the contents of a `Readable` (input character stream) to an `Appendable` (output character stream)
    `long` | `copy​(java.nio.channels.ReadableByteChannel source, java.nio.channels.WritableByteChannel destination)` | Copy the contents of a `ReadableByteChannel` (input byte stream) to a `WritableByteChannel` (output byte stream)
    `java.io.InputStream` | `emptyStream()` | Return an InputStream containing zero bytes
    `boolean` | `isEmptyStream​(java.io.InputStream stream)` | Checks if the specified `InputStream` is the empty stream instance provided by `emptyStream()`.
    `java.io.OutputStream` | `nullStream()` | Return an `OutputStream` that swallows all output silently
    `java.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 a `InputStream` to an `OutputStream`
      Parameters:
        `is` - The stream containing the content
        `os` - 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 a `Readable` (input character stream) to an `Appendable` (output character stream)
      Parameters:
        `source` - The stream containing the content
        `destination` - 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 a `ReadableByteChannel` (input byte stream) to a `WritableByteChannel` (output byte stream)
      Parameters:
        `source` - The stream containing the content
        `destination` - 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 an `OutputStream` 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 specified `InputStream` is the empty stream instance provided by `emptyStream()`.
      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 a `String`. The contents of the byte stream must be encoded in `UTF-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 a `String` .
      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 a `CharSequence` into an `InputStream` instance
      Parameters:
        `text` - The text to be transformed into an `InputStream`
      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 of `InputStream`.
      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 of `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.
      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 a `byte[]` 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 specified `Readable` into a `byte[]` 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 encoded `byte[]` 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 specified `ReadableByteChannel` into a `byte[]` 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