public class IOPipe extends Object
A typical usage is as follows...
InputStream in = getInputStream(); Writer out = getWriter(); IOPipe.create(in, out).closeOut().run();
By default, the input stream is closed and the output stream is not.
This can be changed by calling closeOut()
and close(boolean, boolean)
.
Modifier and Type | Class and Description |
---|---|
static interface |
IOPipe.LineProcessor
Interface to implement for the
lineProcessor(LineProcessor) method. |
Modifier and Type | Method and Description |
---|---|
IOPipe |
buffSize(int buffSize)
Specifies the temporary buffer size.
|
IOPipe |
byLines()
Same as calling
byLines() with |
IOPipe |
byLines(boolean byLines)
Specifies whether the content should be piped line-by-line.
|
IOPipe |
close(boolean in,
boolean out)
Specifies whether to close the input and output after piping.
|
IOPipe |
closeOut()
Close output after piping.
|
static IOPipe |
create(Object input,
Object output)
Creates a new pipe with the specified input and output.
|
IOPipe |
lineProcessor(IOPipe.LineProcessor lineProcessor)
Specifies a line processor that can be used to process lines before they're piped to the output.
|
int |
run()
Performs the piping of the input to the output.
|
public static IOPipe create(Object input, Object output)
input
- The input. Must be one of the following types: Reader, InputStream, CharSequence.output
- The output. Must be one of the following types: Writer, OutputStream.public IOPipe closeOut()
public IOPipe close(boolean in, boolean out)
in
- Close input stream. Default is out
- Close output stream. Default is public IOPipe buffSize(int buffSize)
buffSize
- The buffer size. Default is public IOPipe byLines(boolean byLines)
This can be useful if you're trying to pipe console-based input.
byLines
- Pipe content line-by-line. Default is public IOPipe byLines()
byLines()
with public IOPipe lineProcessor(IOPipe.LineProcessor lineProcessor)
lineProcessor
- The line processor.public int run() throws IOException
IOException
- Thrown by underlying stream.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.