Package org.apache.tools.ant
Class DemuxOutputStream
- java.lang.Object
- 
- java.io.OutputStream
- 
- org.apache.tools.ant.DemuxOutputStream
 
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.io.Flushable,- java.lang.AutoCloseable
 
 public class DemuxOutputStream extends java.io.OutputStreamLogs 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 SummaryConstructors Constructor Description DemuxOutputStream(Project project, boolean isErrorStream)Creates a new instance of this class.
 - 
Method SummaryModifier and Type Method Description voidclose()Equivalent to flushing the stream.voidflush()Writes all remaining data in the buffer associated with the current thread to the project.protected voidprocessBuffer(java.io.ByteArrayOutputStream buffer)Converts the buffer to a string and sends it to the project.protected voidprocessFlush(java.io.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.
 
- 
- 
- 
Constructor Detail- 
DemuxOutputStreampublic DemuxOutputStream(Project project, boolean isErrorStream) Creates a new instance of this class.- Parameters:
- project- The project instance for which output is being demultiplexed. Must not be- null.
- 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 Detail- 
writepublic void write(int cc) throws java.io.IOExceptionWrites 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 class- java.io.OutputStream
- Parameters:
- cc- data to log (byte).
- Throws:
- java.io.IOException- if the data cannot be written to the stream
 
 - 
processBufferprotected void processBuffer(java.io.ByteArrayOutputStream buffer) 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:
- Project.demuxOutput(String,boolean)
 
 - 
processFlushprotected void processFlush(java.io.ByteArrayOutputStream buffer) 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:
- Project.demuxOutput(String,boolean)
 
 - 
closepublic void close() throws java.io.IOExceptionEquivalent to flushing the stream.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Overrides:
- closein class- java.io.OutputStream
- Throws:
- java.io.IOException- if there is a problem closing the stream.
- See Also:
- flush()
 
 - 
flushpublic void flush() throws java.io.IOExceptionWrites all remaining data in the buffer associated with the current thread to the project.- Specified by:
- flushin interface- java.io.Flushable
- Overrides:
- flushin class- java.io.OutputStream
- Throws:
- java.io.IOException- if there is a problem flushing the stream.
 
 - 
writepublic void write(byte[] b, int off, int len) throws java.io.IOExceptionWrite a block of characters to the output stream- Overrides:
- writein class- java.io.OutputStream
- Parameters:
- b- the array containing the data
- off- the offset into the array where data starts
- len- the length of block
- Throws:
- java.io.IOException- if the data cannot be written into the stream.
 
 
- 
 
-