private class EnvCheck.Pipe extends Object implements Runnable
Modifier and Type | Field and Description |
---|---|
private String |
annotation
the output stream annotation
|
private ByteArrayOutputStream |
bufOut
output line buffer
|
private InputStream |
in
the input stream
|
private Thread |
outThread
the thread to process the data
|
private static byte |
SEPARATOR
the line separator character
|
private PrintStream |
stream
the output PrintStream
|
Constructor and Description |
---|
EnvCheck.Pipe(String name,
InputStream in,
PrintStream stream,
String a)
Create a new Pipe object and start the thread to handle the data.
|
Modifier and Type | Method and Description |
---|---|
void |
run()
Read and write data until EOF is detected.
|
(package private) void |
waitTillEmpty(int timeout)
Wait until the run method terminates due to reading EOF on input
|
private void |
write(byte b)
If not annotated, write the byte to the stream immediately.
|
private void |
write(byte[] b,
int len)
Write each byte in the give byte array.
|
private static final byte SEPARATOR
private ByteArrayOutputStream bufOut
private InputStream in
private PrintStream stream
private String annotation
private Thread outThread
EnvCheck.Pipe(String name, InputStream in, PrintStream stream, String a)
name
- the name to assign to the threadin
- input stream from which pipe input flowsstream
- the stream to which output will be senta
- the annotation for prepending text to logged linesvoid waitTillEmpty(int timeout)
timeout
- max time to wait for the thread to terminatepublic void run()
private void write(byte[] b, int len) throws IOException
b
- the array of input byteslen
- the number data bytes in the arrayIOException
private void write(byte b) throws IOException
IOException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.