|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
org.scijava.util.LineOutputStream
public abstract class LineOutputStream
This class hides a line-based output behind an 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.
| Field Summary | |
|---|---|
byte[] |
buffer
|
int |
len
|
| Constructor Summary | |
|---|---|
LineOutputStream()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public byte[] buffer
public int len
| Constructor Detail |
|---|
public LineOutputStream()
| Method Detail |
|---|
public abstract void println(String line)
throws IOException
line - the line to print
IOException
public void write(int b)
throws IOException
flush() the
current line if it is a new-line character.
write in class OutputStreamb - the byte to write
IOException
public void write(byte[] buf)
throws IOException
flush() the current line buffer.
write in class OutputStreambuf - the bytes to write
IOException
public 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 add
IOException
public void close()
throws IOException
close in interface Closeableclose in class OutputStreamIOException
public 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 length
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||