|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fhg.igd.io.Pipe
public class Pipe
This class provides a pipe, which transfers
data from an InputStream
to an
OutputStream
.
The class can be used either in synchronous
(see pipe()
) or in asynchronous
(see start()
) mode.
Field Summary | |
---|---|
private Object |
lock_
The internal lock for synchronisation purpose. |
private long |
pipedBytes_
The number of bytes currently piped in asynchronous mode. |
private InputStream |
pipeIn_
The input stream of the pipe, from which data is read. |
private String |
pipeName_
The name of the pipe, used to identify the corresponding thread in asynchronous mode. |
private OutputStream |
pipeOut_
The output stream of the pipe, to which data is written. |
private Thread |
pipeThread_
The thread responsible to transfer data in asynchronous mode. |
Constructor Summary | |
---|---|
private |
Pipe()
Default constructor disabled. |
|
Pipe(String name,
InputStream in,
OutputStream out)
Creates a new Pipe object with the given input and output streams and the given name.. |
Method Summary | |
---|---|
long |
getPipedBytes()
Returns the number of bytes, already transfered from the pipe's input to its output stream in asynchronous mode. |
long |
pipe()
This method pipes all data from the input stream of the pipe to its output stream, until the EOF of the input stream is reached
or an exception occures during transfer of data. |
static long |
pipe(InputStream in,
OutputStream out)
This method pipes all data from the given input stream to the given output stream, until the EOF of the input stream is reached
or an exception occures during transfer of data. |
void |
run()
The functionality of the pipeThread ,
which transfers data from the pipe's input to
its output stream. |
private void |
start()
Start or restart the pipeThread
to transfer data from the pipe's input
to its output stream in asynchronous mode. |
private void |
stop()
Stops the pipeThread . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Thread pipeThread_
private InputStream pipeIn_
private OutputStream pipeOut_
private String pipeName_
private long pipedBytes_
private Object lock_
Constructor Detail |
---|
private Pipe()
public Pipe(String name, InputStream in, OutputStream out)
name
- the name of the pipe identifies the corresponding
thread in asynchronous mode.in
- the input stream to read from.out
- the output stream to write to.Method Detail |
---|
public static long pipe(InputStream in, OutputStream out) throws IOException
EOF
of the input stream is reached
or an exception occures during transfer of data.
in
- the input stream to read from.out
- the output stream to write to.
IOException
- An exception is thrown, if an error
occures during transfer of data.public long pipe() throws IOException
EOF
of the input stream is reached
or an exception occures during transfer of data.
This method can only be invoked, when the
Pipe
is not currently running
in asynchronous mode.
in
- the input stream to read from.out
- the output stream to write to.
IOException
- An exception is thrown, if an error
occures during transfer of data, or the pipe already
runs in asynchronous mode.private void start()
pipeThread
to transfer data from the pipe's input
to its output stream in asynchronous mode.
The thread is automatically stopped, when the
end of the input stream has been reached or
an exception has occured during transfer of data.
In case the method pipe()
has
been called and is still active, this method
is blocked.
private void stop()
pipeThread
.
public void run()
pipeThread
,
which transfers data from the pipe's input to
its output stream.
This method should not be invoked directly.
run
in interface Runnable
public long getPipedBytes()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |