Package com.swiftmq.tools.util
Class DynamicBufferedOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.swiftmq.tools.util.DynamicBufferedOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class DynamicBufferedOutputStream extends java.io.FilterOutputStream
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
buf
protected int
count
protected static int
DEFAULT_EXTEND_SIZE
protected static int
DEFAULT_MAX_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description DynamicBufferedOutputStream(java.io.OutputStream out)
DynamicBufferedOutputStream(java.io.OutputStream out, int size)
DynamicBufferedOutputStream(java.io.OutputStream out, int extendSize, int maxSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
Flushes this buffered output stream.void
write(byte[] b, int off, int len)
Writeslen
bytes from the specified byte array starting at offsetoff
to this buffered output stream.void
write(int b)
Writes the specified byte to this buffered output stream.
-
-
-
Field Detail
-
DEFAULT_MAX_BUFFER_SIZE
protected static final int DEFAULT_MAX_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_EXTEND_SIZE
protected static final int DEFAULT_EXTEND_SIZE
- See Also:
- Constant Field Values
-
buf
protected byte[] buf
-
count
protected int count
-
-
Constructor Detail
-
DynamicBufferedOutputStream
public DynamicBufferedOutputStream(java.io.OutputStream out, int extendSize, int maxSize)
-
DynamicBufferedOutputStream
public DynamicBufferedOutputStream(java.io.OutputStream out)
-
DynamicBufferedOutputStream
public DynamicBufferedOutputStream(java.io.OutputStream out, int size)
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
Writes the specified byte to this buffered output stream.- Overrides:
write
in classjava.io.FilterOutputStream
- Parameters:
b
- the byte to be written.- Throws:
java.io.IOException
- if an I/O error occurs.
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
Writeslen
bytes from the specified byte array starting at offsetoff
to this buffered output stream.Ordinarily this method stores bytes from the given array into this stream's buffer, flushing the buffer to the underlying output stream as needed. If the requested length is at least as large as this stream's buffer, however, then this method will flush the buffer and write the bytes directly to the underlying output stream. Thus redundant
BufferedOutputStream
s will not copy data unnecessarily.- Overrides:
write
in classjava.io.FilterOutputStream
- Parameters:
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.- Throws:
java.io.IOException
- if an I/O error occurs.
-
flush
public void flush() throws java.io.IOException
Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream.- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- if an I/O error occurs.- See Also:
FilterOutputStream.out
-
-