org.apache.ode.utils

## Class StreamUtils

- java.lang.Object
- - org.apache.ode.utils.StreamUtils

-     public class StreamUtils
      extends java.lang.Object

  Utilities for dealing with byte (`InputStream` and `OutputStream`) and character (`Reader` and `Writer`) streams.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_BUFFER_SIZE` The default size of the byte buffer used in the `copy(java.io.OutputStream, java.io.InputStream, int)` methods.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StreamUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `copy(java.io.OutputStream dest, java.io.InputStream source)` Copy with default buffer size.
    `static void` | `copy(java.io.OutputStream dest, java.io.InputStream source, int bufSize)` Copy data from an `InputStream` to an `OutputStream` until an end-of-stream is reached on the source `InputStream`.
    `static void` | `copy(java.io.OutputStream dest, java.net.URL source)` Copy from `URL` stream.
    `static void` | `copy(java.io.Writer dest, java.io.Reader source, int bufSize)` Copy data from an `Reader` to an `Writer` until an end-of-stream is reached on the source `Reader`.
    `static void` | `extractJar(java.io.File dest, java.io.InputStream is)` Expand a Jar input stream.
    `static byte[]` | `read(java.io.InputStream source)` Read the contents of the given InputStream into a byte array.
    `static byte[]` | `read(java.net.URL input)` Read the contents of the given URL into a byte array.
    `static java.lang.Object` | `readObj(java.io.InputStream is)`
    `static void` | `write(java.io.OutputStream dest, java.io.Serializable src)` Write a `Serializable` object to an output stream using the `ObjectOutputStream` mechanism.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_BUFFER_SIZE

          public static final int DEFAULT_BUFFER_SIZE

      The default size of the byte buffer used in the `copy(java.io.OutputStream, java.io.InputStream, int)` methods.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### StreamUtils

          public StreamUtils()

  - ### Method Detail

    - #### read

          public static byte[] read(java.net.URL input)
                             throws java.io.IOException

      Read the contents of the given URL into a byte array.
      Parameters:
        `input` - the URL to read
      Returns:
        an array of bytes.
      Throws:
        `java.io.IOException` - in case of I/O error

    - #### read

          public static byte[] read(java.io.InputStream source)
                             throws java.io.IOException

      Read the contents of the given InputStream into a byte array.
      Parameters:
        `input` - the InputStream to read
      Returns:
        an array of bytes.
      Throws:
        `java.io.IOException` - in case of I/O error

    - #### copy

          public static void copy(java.io.OutputStream dest,
                  java.io.InputStream source,
                  int bufSize)
                           throws java.io.IOException

      Copy data from an `InputStream` to an `OutputStream` until an end-of-stream is reached on the source `InputStream`. This method does not attempt to close either the source or the destination stream.
      Parameters:
        `dest` - destination `OutputStream`
        `source` - source `InputStream`
        `bufSize` - write buffer size
      Throws:
        `java.io.IOException` - in case of I/O error

    - #### copy

          public static void copy(java.io.Writer dest,
                  java.io.Reader source,
                  int bufSize)
                           throws java.io.IOException

      Copy data from an `Reader` to an `Writer` until an end-of-stream is reached on the source `Reader`. This method does not attempt to close either the source or the destination stream.
      Parameters:
        `dest` - destination `Writer`
        `source` - source `Reader`
        `bufSize` - write buffer size
      Throws:
        `java.io.IOException` - in case of I/O error

    - #### copy

          public static void copy(java.io.OutputStream dest,
                  java.io.InputStream source)
                           throws java.io.IOException

      Copy with default buffer size.
      Throws:
        `java.io.IOException`
      See Also:
        `copy(java.io.OutputStream, java.io.InputStream)`, `DEFAULT_BUFFER_SIZE`

    - #### copy

          public static void copy(java.io.OutputStream dest,
                  java.net.URL source)
                           throws java.io.IOException

      Copy from `URL` stream.
      Parameters:
        `dest` - destination `OutputStream`
        `source` - source `URL`
      Throws:
        `java.io.IOException`
      See Also:
        `copy(java.io.OutputStream, java.io.InputStream, int)`

    - #### write

          public static void write(java.io.OutputStream dest,
                   java.io.Serializable src)
                            throws java.io.IOException

      Write a `Serializable` object to an output stream using the `ObjectOutputStream` mechanism.
      Parameters:
        `dest` - destination `OutputStream`
        `src` - source `Serializable`
      Throws:
        `java.io.IOException`

    - #### readObj

          public static java.lang.Object readObj(java.io.InputStream is)
                                          throws java.io.IOException,
                                                 java.lang.ClassNotFoundException

      Throws:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`

    - #### extractJar

          public static void extractJar(java.io.File dest,
                        java.io.InputStream is)
                                 throws java.io.IOException

      Expand a Jar input stream.
      Throws:
        `java.io.IOException`