public class Outputs extends Object
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> |
withReceiver(Receiver<T,ReceiverThrowableType> receiver)
Use given receiver as Output.
|
public static Output<String,IOException> text(File file)
If the filename ends with .gz, then the data is automatically GZipped.
file
- the file to save the text topublic static Output<String,IOException> text(File file, String encoding)
If the filename ends with .gz, then the data is automatically GZipped.
file
- the file to save the text topublic static Output<String,IOException> text(Writer writer)
writer
- the Writer to write the text topublic static Output<String,IOException> text(StringBuilder builder)
builder
- the StringBuilder to append the text topublic static Output<ByteBuffer,IOException> byteBuffer(File file)
file
- The destination file.public static Output<ByteBuffer,IOException> byteBuffer(OutputStream stream)
stream
- Destination OutputStreampublic static Output<byte[],IOException> bytes(File file, int bufferSize)
file
- The File to be written to.bufferSize
- The size of the ByteBuffer.public static <T> Output<T,RuntimeException> noop()
T
- The item type.public static <T,ReceiverThrowableType extends Throwable> Output<T,ReceiverThrowableType> withReceiver(Receiver<T,ReceiverThrowableType> receiver)
T
- The item typereceiver
- receiver for this Outputpublic static Output<Object,RuntimeException> systemOut()
public static Output<Object,RuntimeException> systemErr()
public static <T> Output<T,RuntimeException> collection(Collection<T> collection)