edu.rit.io
Class LineBufferedOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- edu.rit.io.LineBufferedOutputStream
-
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
public class LineBufferedOutputStream extends java.io.FilterOutputStreamClass 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.
-
-
Constructor Summary
Constructors Constructor and Description LineBufferedOutputStream(java.io.OutputStream out)Construct a new line buffered output stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()Close this line buffered output stream.voidflush()Flush this line buffered output stream.voidwrite(byte[] buf)Write the given byte array to this line buffered output stream.voidwrite(byte[] buf, int off, int len)Write a portion of the given byte array to this line buffered output stream.voidwrite(int b)Write the given byte to this line buffered output stream.
-
-
-
Constructor Detail
-
LineBufferedOutputStream
public LineBufferedOutputStream(java.io.OutputStream out)
Construct a new line buffered output stream.- Parameters:
out- Underlying output stream.
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOExceptionWrite the given byte to this line buffered output stream. Only the least significant 8 bits of b are written.- Overrides:
writein classjava.io.FilterOutputStream- Parameters:
b- Byte.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
write
public void write(byte[] buf) throws java.io.IOExceptionWrite the given byte array to this line buffered output stream.- Overrides:
writein classjava.io.FilterOutputStream- Parameters:
buf- Byte array.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if buf is null.java.io.IOException- Thrown if an I/O error occurred.
-
write
public void write(byte[] buf, int off, int len) throws java.io.IOExceptionWrite a portion of the given byte array to this line buffered output stream.- Overrides:
writein classjava.io.FilterOutputStream- Parameters:
buf- Byte array.off- Index of first byte to write.len- Number of bytes to write.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if buf is null.java.lang.IndexOutOfBoundsException- (unchecked exception) Thrown if off < 0, len < 0, or off+len > buf.length.java.io.IOException- Thrown if an I/O error occurred.
-
flush
public void flush() throws java.io.IOExceptionFlush this line buffered output stream. The flush() method does nothing.- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.FilterOutputStream- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
close
public void close() throws java.io.IOExceptionClose this line buffered output stream.- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacejava.lang.AutoCloseable- Overrides:
closein classjava.io.FilterOutputStream- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
-
DMelt 3.0 © DataMelt by jWork.ORG