public abstract class LineOutputStream extends OutputStream
OutputStream.
Only the abstract method println(String) needs to be overridden; the
other methods in OutputStream are overridden in this class already to
buffer lines until they are complete and then flush them.
| Constructor and Description |
|---|
LineOutputStream() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Flushes the current line buffer if any bytes are left in it.
|
protected void |
ensure(int length)
Increases the size of the line buffer if necessary.
|
void |
flush()
If any bytes are in the current line buffer, output the line via
println(String), stripping any trailing new-line characters. |
abstract void |
println(String line)
This method is all that needs to be implemented.
|
void |
write(byte[] buf)
Adds bytes to the current line buffer.
|
void |
write(byte[] buf,
int offset,
int length)
Adds bytes to the current line buffer.
|
void |
write(int b)
Adds a single byte to the current line buffer, or
flush() the
current line if it is a new-line character. |
public abstract void println(String line) throws IOException
line - the line to printIOExceptionpublic void write(int b)
throws IOException
flush() the
current line if it is a new-line character.write in class OutputStreamb - the byte to writeIOExceptionpublic void write(byte[] buf)
throws IOException
flush() the current line buffer.write in class OutputStreambuf - the bytes to writeIOExceptionpublic void write(byte[] buf,
int offset,
int length)
throws IOException
flush() the current line buffer.write in class OutputStreambuf - the bytes to writeoffset - the offset into the bufferlength - how many bytes to addIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic void flush()
throws IOException
println(String), stripping any trailing new-line characters.flush in interface Flushableflush in class OutputStreamIOExceptionprotected void ensure(int length)
length - the required minimal lengthCopyright © 2009–2016 SciJava. All rights reserved.