Package com.castlabs.utils

## Class IOUtils

- java.lang.Object
- - com.castlabs.utils.IOUtils

-     public class IOUtils
      extends Object

  Utility functions for IO operations
  Since:
    2.0.0

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `IOUtils()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `closeQuietly​(com.google.android.exoplayer2.upstream.DataSource closeable)` | Quietly close the given DataSource and ignore any IO exceptions.
    `static void` | `closeQuietly​(Closeable closeable)` | Quietly close the given closable and ignore any IO exceptions.
    `static void` | `copy​(InputStream input, OutputStream output)` | Copy the content from the input to the output stream and closes both the input and the output stream
    `static void` | `copy​(InputStream input, Writer writer)` | Copy the input stream content as UTF-8 chars to the writer
    `static void` | `copy​(Reader reader, Writer writer)` | Copy the content from teh given reader to the given writer and closes reader and writer
    `static byte[]` | `toByteArray​(InputStream content)` | Read and return the content of the given stream as byte[]
    `static String` | `toString​(InputStream content)` | Gets the contents of an InputStream as a String assuming UTF8 encoding

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

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

- - ### Constructor Detail

    - #### IOUtils

          public IOUtils()

  - ### Method Detail

    - #### toString

          public static String toString​(InputStream content)
                                 throws IOException

      Gets the contents of an InputStream as a String assuming UTF8 encoding
      Parameters:
        `content` - the input
      Returns:
        content of the given input stream as String
      Throws:
        `IOException` - in case of any errors

    - #### toByteArray

          public static byte[] toByteArray​(InputStream content)
                                    throws IOException

      Read and return the content of the given stream as byte[]
      Parameters:
        `content` - the content
      Returns:
        byte array of the content of the stream
      Throws:
        `IOException` - in case of any errors

    - #### closeQuietly

          public static void closeQuietly​(@Nullable
                                          Closeable closeable)

      Quietly close the given closable and ignore any IO exceptions. Null input will be ignored.
      Parameters:
        `closeable` - the closable. If null the method will just return.

    - #### closeQuietly

          public static void closeQuietly​(@Nullable
                                          com.google.android.exoplayer2.upstream.DataSource closeable)

      Quietly close the given DataSource and ignore any IO exceptions. Null input will be ignored.
      Parameters:
        `closeable` - the closable. If null the method will just return.

    - #### copy

          public static void copy​(InputStream input,
                                  Writer writer)
                           throws IOException

      Copy the input stream content as UTF-8 chars to the writer
      Parameters:
        `input` - input stream
        `writer` - output writer
      Throws:
        `IOException` - in case of an error

    - #### copy

          public static void copy​(Reader reader,
                                  Writer writer)
                           throws IOException

      Copy the content from teh given reader to the given writer and closes reader and writer
      Parameters:
        `reader` - the reader
        `writer` - the writer
      Throws:
        `IOException` - in case of an error

    - #### copy

          public static void copy​(InputStream input,
                                  OutputStream output)
                           throws IOException

      Copy the content from the input to the output stream and closes both the input and the output stream
      Parameters:
        `input` - the input stream
        `output` - the output stream
      Throws:
        `IOException` - in case of an IO error while reading or writing the streams