org.qi4j.io

## Class Inputs

- java.lang.Object
- - org.qi4j.io.Inputs

-     public class Inputs
      extends Object

  Common inputs

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Input<ByteBuffer,IOException>` | `byteBuffer(File source, int bufferSize)` Read a file using ByteBuffer of a given size.
    `static Input<ByteBuffer,IOException>` | `byteBuffer(InputStream source, int bufferSize)` Read an inputstream using ByteBuffer of a given size.
    `static <T,SenderThrowableType extends Throwable> Input<T,SenderThrowableType>` | `combine(Iterable<Input<T,SenderThrowableType>> inputs)` Combine many Input into one single Input.
    `static <T> Input<T,RuntimeException>` | `iterable(Iterable<T> iterable)` Create an Input that takes its items from the given Iterable.
    `static Input<ByteBuffer,IOException>` | `output(Visitor<OutputStream,IOException> outputVisitor, int bufferSize)` Create an Input that allows a Visitor to write to an OutputStream.
    `static Input<String,IOException>` | `text(File source)` Read lines from a UTF-8 encoded textfile.
    `static Input<String,IOException>` | `text(File source, String encoding)` Read lines from a textfile with the given encoding.
    `static Input<String,RuntimeException>` | `text(Reader source)` Read lines from a Reader.
    `static Input<String,RuntimeException>` | `text(String source)` Read lines from a String.
    `static Input<String,IOException>` | `text(URL source)` Read lines from a textfile at a given URL.

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

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

- - ### Method Detail

    - #### text

          public static Input<String,RuntimeException> text(String source)

      Read lines from a String.
      Parameters:
        `source` - lines
      Returns:
        Input that provides lines from the string as strings

    - #### text

          public static Input<String,RuntimeException> text(Reader source)

      Read lines from a Reader.
      Parameters:
        `source` - lines
      Returns:
        Input that provides lines from the string as strings

    - #### text

          public static Input<String,IOException> text(File source)

      Read lines from a UTF-8 encoded textfile. If the filename ends with .gz, then the data is automatically unzipped when read.
      Parameters:
        `source` - textfile with lines separated by \n character
      Returns:
        Input that provides lines from the textfiles as strings

    - #### text

          public static Input<String,IOException> text(File source,
                                       String encoding)

      Read lines from a textfile with the given encoding. If the filename ends with .gz, then the data is automatically unzipped when read.
      Parameters:
        `source` - textfile with lines separated by \n character
        `encoding` - encoding of file, e.g. "UTF-8"
      Returns:
        Input that provides lines from the textfiles as strings

    - #### text

          public static Input<String,IOException> text(URL source)

      Read lines from a textfile at a given URL. If the content support gzip encoding, then the data is automatically unzipped when read. The charset in the content-type of the URL will be used for parsing. Default is UTF-8.
      Parameters:
        `source` - textfile with lines separated by \n character
      Returns:
        Input that provides lines from the textfiles as strings

    - #### byteBuffer

          public static Input<ByteBuffer,IOException> byteBuffer(File source,
                                                 int bufferSize)

      Read a file using ByteBuffer of a given size. Useful for transferring raw data.
      Parameters:
        `source` - The file to be read.
        `bufferSize` - The size of the byte array.
      Returns:
        An Input instance to be applied to streaming operations.

    - #### byteBuffer

          public static Input<ByteBuffer,IOException> byteBuffer(InputStream source,
                                                 int bufferSize)

      Read an inputstream using ByteBuffer of a given size.
      Parameters:
        `source` - The InputStream to be read.
        `bufferSize` - The size of the byte array.
      Returns:
        An Input instance to be applied to streaming operations.

    - #### combine

          public static <T,SenderThrowableType extends Throwable> Input<T,SenderThrowableType> combine(Iterable<Input<T,SenderThrowableType>> inputs)

      Combine many Input into one single Input. When a transfer is initiated from it all items from all inputs will be transferred to the given Output.
      Type Parameters:
        `T` - The item type of the Input
        `SenderThrowableType` - The Throwable that might be thrown by the Inputs.
      Parameters:
        `inputs` - An Iterable of Input instances to be combined.
      Returns:
        A combined Input, allowing for easy aggregation of many Input sources.

    - #### iterable

          public static <T> Input<T,RuntimeException> iterable(Iterable<T> iterable)

      Create an Input that takes its items from the given Iterable.
      Type Parameters:
        `T` - The item type of the Input
      Parameters:
        `iterable` - The Iterable to be used as an Input.
      Returns:
        An Input instance that is backed by the Iterable.

    - #### output

          public static Input<ByteBuffer,IOException> output(Visitor<OutputStream,IOException> outputVisitor,
                                             int bufferSize)

      Create an Input that allows a Visitor to write to an OutputStream. The stream is a BufferedOutputStream, so when enough data has been gathered it will send this in chunks of the given size to the Output it is transferred to. The Visitor does not have to call close() on the OutputStream, but should ensure that any wrapper streams or writers are flushed so that all data is sent.
      Parameters:
        `outputVisitor` - The OutputStream Visitor that will be backing the Input ByteBuffer.
        `bufferSize` - The buffering size.
      Returns:
        An Input instance of ByteBuffer, that is backed by an Visitor to an OutputStream.