Top Description Fields Constructors Methods
org.apache.tools.ant.util

public abstract Class LineOrientedOutputStream

extends OutputStream
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.util.LineOrientedOutputStreamRedirector, org.apache.tools.ant.taskdefs.LogOutputStream, org.apache.tools.ant.taskdefs.cvslib.RedirectingOutputStream
Imports
java.io.ByteArrayOutputStream, .IOException, .OutputStream

Invokes processLine whenever a full line has been written to this stream.

Tries to be smart about line separators.

Field Summary

Modifier and TypeField and Description
private ByteArrayOutputStream
private static final int
CR

Carriage return

private static final int
INITIAL_SIZE

Initial buffer size.

private static final int
LF

Linefeed

private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Writes all remaining
public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flush this log stream
protected void
processBuffer()

Converts the buffer to a byte[] and sends it to processLine

protected abstract void
processLine(String
the line to log.
line
)

Processes a line.

protected void
processLine(byte[]
the line to log.
line
)

Processes a line.

public final void
write(int
data to log (byte).
cc
)

Implements abstract java.io.OutputStream.write.

Write the data to the buffer and flush the buffer, if a line separator is detected.
public final void
write(byte[]
the array containing the data
b
,
int
the offset into the array where data starts
off
,
int
the length of block
len
)

Overrides java.io.OutputStream.write.

Write a block of characters to the output stream
Inherited from java.io.OutputStream:
nullOutputStreamwrite

Field Detail

bufferback to summary
private ByteArrayOutputStream buffer
CRback to summary
private static final int CR

Carriage return

INITIAL_SIZEback to summary
private static final int INITIAL_SIZE

Initial buffer size.

LFback to summary
private static final int LF

Linefeed

skipback to summary
private boolean skip

Constructor Detail

LineOrientedOutputStreamback to summary
public LineOrientedOutputStream()

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Writes all remaining

Annotations
@Override
Exceptions
IOException:
if there is an error.
flushback to summary
public void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flush this log stream

Annotations
@Override
Exceptions
IOException:
if there is an error.
processBufferback to summary
protected void processBuffer() throws IOException

Converts the buffer to a byte[] and sends it to processLine

Exceptions
IOException:
if there is an error.
processLineback to summary
protected abstract void processLine(String line) throws IOException

Processes a line.

Parameters
line:String

the line to log.

Exceptions
IOException:
if there is an error.
processLineback to summary
protected void processLine(byte[] line) throws IOException

Processes a line.

This implementations invokes the string-arg version converting the byte array using the default encoding. Subclasses are encouraged to override this method (and provide a dummy implementation of the String-arg version) so they don't interfere with the encoding of the underlying stream.

Parameters
line:byte[]

the line to log.

Exceptions
IOException:
if there is an error.
Since
Ant 1.8.3
writeback to summary
public final void write(int cc) throws IOException

Implements abstract java.io.OutputStream.write.

Write the data to the buffer and flush the buffer, if a line separator is detected.

Parameters
cc:int

data to log (byte).

Annotations
@Override
Exceptions
IOException:
if there is an error.
writeback to summary
public final void write(byte[] b, int off, int len) throws IOException

Overrides java.io.OutputStream.write.

Write a block of characters to the output stream

Parameters
b:byte[]

the array containing the data

off:int

the offset into the array where data starts

len:int

the length of block

Annotations
@Override
Exceptions
IOException:
if the data cannot be written into the stream.