Package edu.rit.io
Class LineBufferedOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
edu.rit.io.LineBufferedOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Class LineBufferedOutputStream provides a line buffer layered on top of an
underlying output stream. All writes to the line buffered output stream are
accumulated in an internal buffer. Calling
flush()
on the line
buffered output stream does nothing. The only times the internal buffer is
flushed to the underlying output stream are when a newline byte
('\n'
) is written and when the line buffered output stream is
closed.- Version:
- 19-Oct-2006
- Author:
- Alan Kaminsky
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorDescriptionConstruct a new line buffered output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this line buffered output stream.void
flush()
Flush this line buffered output stream.void
write
(byte[] buf) Write the given byte array to this line buffered output stream.void
write
(byte[] buf, int off, int len) Write a portion of the given byte array to this line buffered output stream.void
write
(int b) Write the given byte to this line buffered output stream.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
LineBufferedOutputStream
Construct a new line buffered output stream.- Parameters:
out
- Underlying output stream.
-
-
Method Details
-
write
Write the given byte to this line buffered output stream. Only the least significant 8 bits ofb
are written.- Overrides:
write
in classFilterOutputStream
- Parameters:
b
- Byte.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
write
Write the given byte array to this line buffered output stream.- Overrides:
write
in classFilterOutputStream
- Parameters:
buf
- Byte array.- Throws:
NullPointerException
- (unchecked exception) Thrown ifbuf
is null.IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
write
Write a portion of the given byte array to this line buffered output stream.- Overrides:
write
in classFilterOutputStream
- Throws:
NullPointerException
- (unchecked exception) Thrown ifbuf
is null.IndexOutOfBoundsException
- (unchecked exception) Thrown ifoff
< 0,len
< 0, oroff+len
>buf.length
.IOException
- Thrown if an I/O error occurred.
-
flush
Flush this line buffered output stream. Theflush()
method does nothing.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterOutputStream
- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
close
Close this line buffered output stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-