LineOrientedOutputStream (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.util, class: LineOrientedOutputStream

Package org.apache.tools.ant.util

# Class LineOrientedOutputStream

java.lang.Object
java.io.OutputStream
org.apache.tools.ant.util.LineOrientedOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

Direct Known Subclasses:
  `LineOrientedOutputStreamRedirector`, `LogOutputStream`

public abstract class LineOrientedOutputStream extends OutputStream
Invokes `processLine` whenever a full line has been written to this stream.

Tries to be smart about line separators.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LineOrientedOutputStream()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Writes all remaining
  `void`
  `flush()`
  Flush this log stream
  `protected void`
  `processBuffer()`
  Converts the buffer to a byte[] and sends it to `processLine`
  `protected void`
  `processLine(byte[] line)`
  Processes a line.
  `protected abstract void`
  `processLine(String line)`
  Processes a line.
  `final void`
  `write(byte[] b, int off, int len)`
  Write a block of characters to the output stream
  `final void`
  `write(int cc)`
  Write the data to the buffer and flush the buffer, if a line separator is detected.

  ### Methods inherited from class java.io.OutputStream

  `nullOutputStream, write`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LineOrientedOutputStream

    public LineOrientedOutputStream()

- ## Method Details

  - ### write

    public final void write(int cc) throws IOException
    Write the data to the buffer and flush the buffer, if a line separator is detected.
    Specified by:
      `write` in class `OutputStream`
    Parameters:
      `cc` - data to log (byte).
    Throws:
      `IOException` - if there is an error.

  - ### flush

    public void flush() throws IOException
    Flush this log stream
    Specified by:
      `flush` in interface `Flushable`
    Overrides:
      `flush` in class `OutputStream`
    Throws:
      `IOException` - if there is an error.

  - ### processBuffer

    protected void processBuffer() throws IOException
    Converts the buffer to a byte[] and sends it to `processLine`
    Throws:
      `IOException` - if there is an error.

  - ### processLine

    protected abstract void processLine(String line) throws IOException
    Processes a line.
    Parameters:
      `line` - the line to log.
    Throws:
      `IOException` - if there is an error.

  - ### processLine

    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` - the line to log.
    Throws:
      `IOException` - if there is an error.
    Since:
      Ant 1.8.3

  - ### close

    public void close() throws IOException
    Writes all remaining
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Overrides:
      `close` in class `OutputStream`
    Throws:
      `IOException` - if there is an error.

  - ### write

    public final void write(byte[] b, int off, int len) throws IOException
    Write a block of characters to the output stream
    Overrides:
      `write` in class `OutputStream`
    Parameters:
      `b` - the array containing the data
      `off` - the offset into the array where data starts
      `len` - the length of block
    Throws:
      `IOException` - if the data cannot be written into the stream.