Package org.apache.tools.ant
Class DemuxOutputStream
java.lang.Object
java.io.OutputStream
org.apache.tools.ant.DemuxOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Logs content written by a thread and forwards the buffers onto the
project object which will forward the content to the appropriate
task.
- Since:
- 1.4
-
Constructor Summary
ConstructorsConstructorDescriptionDemuxOutputStream(Project project, boolean isErrorStream) Creates a new instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Equivalent to flushing the stream.voidflush()Writes all remaining data in the buffer associated with the current thread to the project.protected voidprocessBuffer(ByteArrayOutputStream buffer) Converts the buffer to a string and sends it to the project.protected voidprocessFlush(ByteArrayOutputStream buffer) Converts the buffer to a string and sends it to the project.voidwrite(byte[] b, int off, int len) Write a block of characters to the output streamvoidwrite(int cc) Writes the data to the buffer and flushes the buffer if a line separator is detected or if the buffer has reached its maximum size.Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
DemuxOutputStream
Creates a new instance of this class.- Parameters:
project- The project instance for which output is being demultiplexed. Must not benull.isErrorStream-trueif this is the error string, otherwise a normal output stream. This is passed to the project so it knows which stream it is receiving.
-
-
Method Details
-
write
Writes the data to the buffer and flushes the buffer if a line separator is detected or if the buffer has reached its maximum size.- Specified by:
writein classOutputStream- Parameters:
cc- data to log (byte).- Throws:
IOException- if the data cannot be written to the stream
-
processBuffer
Converts the buffer to a string and sends it to the project.- Parameters:
buffer- the ByteArrayOutputStream used to collect the output until a line separator is seen.- See Also:
-
processFlush
Converts the buffer to a string and sends it to the project.- Parameters:
buffer- the ByteArrayOutputStream used to collect the output until a line separator is seen.- See Also:
-
close
Equivalent to flushing the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if there is a problem closing the stream.- See Also:
-
flush
Writes all remaining data in the buffer associated with the current thread to the project.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if there is a problem flushing the stream.
-
write
Write a block of characters to the output stream- Overrides:
writein classOutputStream- Parameters:
b- the array containing the dataoff- the offset into the array where data startslen- the length of block- Throws:
IOException- if the data cannot be written into the stream.
-