org.qi4j.io

## Class Outputs

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

-     public class Outputs
      extends Object

  Utility methods for creating standard Outputs

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Output<ByteBuffer,IOException>` | `byteBuffer(File file)` Write ByteBuffer data to a file.
    `static Output<ByteBuffer,IOException>` | `byteBuffer(OutputStream stream)` Write ByteBuffer data to an OutputStream.
    `static Output<byte[],IOException>` | `bytes(File file, int bufferSize)` Write byte array data to a file.
    `static <T> Output<T,RuntimeException>` | `collection(Collection<T> collection)` Add items to a collection
    `static <T> Output<T,RuntimeException>` | `noop()` Do nothing.
    `static Output<Object,RuntimeException>` | `systemErr()` Write objects to System.err.println.
    `static Output<Object,RuntimeException>` | `systemOut()` Write objects to System.out.println.
    `static Output<String,IOException>` | `text(File file)` Write lines to a text file with UTF-8 encoding.
    `static Output<String,IOException>` | `text(File file, String encoding)` Write lines to a text file.
    `static Output<String,IOException>` | `text(StringBuilder builder)` Write lines to a StringBuilder.
    `static Output<String,IOException>` | `text(Writer writer)` Write lines to a Writer.
    `static <T,ReceiverThrowableType extends Throwable> Output<T,ReceiverThrowableType>` | `withReceiver(Receiver<T,ReceiverThrowableType> receiver)` Use given receiver as Output.

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

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

- - ### Method Detail

    - #### text

          public static Output<String,IOException> text(File file)

      Write lines to a text file with UTF-8 encoding. Separate each line with a newline ("\n" character). If the writing or sending fails, the file is deleted.

      If the filename ends with .gz, then the data is automatically GZipped.

      Parameters:
        `file` - the file to save the text to
      Returns:
        an Output for storing text in a file

    - #### text

          public static Output<String,IOException> text(File file,
                                        String encoding)

      Write lines to a text file. Separate each line with a newline ("\n" character). If the writing or sending fails, the file is deleted.

      If the filename ends with .gz, then the data is automatically GZipped.

      Parameters:
        `file` - the file to save the text to
      Returns:
        an Output for storing text in a file

    - #### text

          public static Output<String,IOException> text(Writer writer)

      Write lines to a Writer. Separate each line with a newline ("\n" character).
      Parameters:
        `writer` - the Writer to write the text to
      Returns:
        an Output for storing text in a Writer

    - #### text

          public static Output<String,IOException> text(StringBuilder builder)

      Write lines to a StringBuilder. Separate each line with a newline ("\n" character).
      Parameters:
        `builder` - the StringBuilder to append the text to
      Returns:
        an Output for storing text in a StringBuilder

    - #### byteBuffer

          public static Output<ByteBuffer,IOException> byteBuffer(File file)

      Write ByteBuffer data to a file. If the writing or sending of data fails the file will be deleted.
      Parameters:
        `file` - The destination file.
      Returns:
        The Output ByteBuffer instance backed by a File.

    - #### byteBuffer

          public static Output<ByteBuffer,IOException> byteBuffer(OutputStream stream)

      Write ByteBuffer data to an OutputStream.
      Parameters:
        `stream` - Destination OutputStream
      Returns:
        The Output of ByteBuffer that will be backed by the OutputStream.

    - #### bytes

          public static Output<byte[],IOException> bytes(File file,
                                         int bufferSize)

      Write byte array data to a file. If the writing or sending of data fails the file will be deleted.
      Parameters:
        `file` - The File to be written to.
        `bufferSize` - The size of the ByteBuffer.
      Returns:
        An Output instance that will write to the given File.

    - #### noop

          public static <T> Output<T,RuntimeException> noop()

      Do nothing. Use this if you have all logic in filters and/or specifications
      Type Parameters:
        `T` - The item type.
      Returns:
        An Output instance that ignores all data.

    - #### withReceiver

          public static <T,ReceiverThrowableType extends Throwable> Output<T,ReceiverThrowableType> withReceiver(Receiver<T,ReceiverThrowableType> receiver)

      Use given receiver as Output. Use this if there is no need to create a "transaction" for each transfer, and no need to do batch writes or similar.
      Type Parameters:
        `T` - The item type
      Parameters:
        `receiver` - receiver for this Output
      Returns:
        An Output instance backed by a Receiver of items.

    - #### systemOut

          public static Output<Object,RuntimeException> systemOut()

      Write objects to System.out.println.
      Returns:
        An Output instance that is backed by System.out

    - #### systemErr

          public static Output<Object,RuntimeException> systemErr()

      Write objects to System.err.println.
      Returns:
        An Output instance backed by System.in

    - #### collection

          public static <T> Output<T,RuntimeException> collection(Collection<T> collection)

      Add items to a collection