org.qi4j.api.io
Class Inputs

java.lang.Object
  extended by org.qi4j.api.io.Inputs

public class Inputs
extends Object

Common inputs


Constructor Summary
Inputs()
           
 
Method Summary
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)
           
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,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
 

Constructor Detail

Inputs

public Inputs()
Method Detail

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 byte data form one input to another.

Parameters:
source -
bufferSize -
Returns:

byteBuffer

public static Input<ByteBuffer,IOException> byteBuffer(InputStream source,
                                                       int bufferSize)
Read an inputstream using ByteBuffer of a given size.

Parameters:
source -
bufferSize -
Returns:

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 -
SenderThrowableType -
Parameters:
inputs -
Returns:

iterable

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