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 printIOException
public void write(int b) throws IOException
flush()
the
current line if it is a new-line character.write
in class OutputStream
b
- the byte to writeIOException
public void write(byte[] buf) throws IOException
flush()
the current line buffer.write
in class OutputStream
buf
- the bytes to writeIOException
public void write(byte[] buf, int offset, int length) throws IOException
flush()
the current line buffer.write
in class OutputStream
buf
- the bytes to writeoffset
- the offset into the bufferlength
- how many bytes to addIOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void flush() throws IOException
println(String)
, stripping any trailing new-line characters.flush
in interface Flushable
flush
in class OutputStream
IOException
protected void ensure(int length)
length
- the required minimal lengthCopyright © 2015–2022 SciJava. All rights reserved.