Package org.apache.derby.impl.io.vfmem
Class BlockedByteArrayOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.apache.derby.impl.io.vfmem.BlockedByteArrayOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class BlockedByteArrayOutputStream extends java.io.OutputStreamOutput stream writing bytes into an underlying blocked byte array.
-
-
Field Summary
Fields Modifier and Type Field Description private longposThe current position of the stream.private BlockedByteArraysrcThe underlying destination.
-
Constructor Summary
Constructors Constructor Description BlockedByteArrayOutputStream(BlockedByteArray src, long pos)Creates a new stream writing data into the specified blocked byte array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the stream.(package private) longgetPosition()Returns the current position.(package private) voidsetPosition(long newPos)Sets the position.voidwrite(byte[] buf, int offset, int len)Writes the specified bytes into the underlying blocked byte array.voidwrite(int b)Writes the single byte into the underlying blocked byte array.
-
-
-
Field Detail
-
src
private BlockedByteArray src
The underlying destination. Set tonullwhen closed.
-
pos
private long pos
The current position of the stream.
-
-
Constructor Detail
-
BlockedByteArrayOutputStream
public BlockedByteArrayOutputStream(BlockedByteArray src, long pos)
Creates a new stream writing data into the specified blocked byte array.- Parameters:
src- the underlying blocked byte arraypos- the initial position of stream
-
-
Method Detail
-
setPosition
void setPosition(long newPos)
Sets the position.- Parameters:
newPos- the new byte position
-
getPosition
long getPosition()
Returns the current position.- Returns:
- The current byte position.
-
write
public void write(int b)
Writes the single byte into the underlying blocked byte array.- Specified by:
writein classjava.io.OutputStream- Parameters:
b- the byte to write
-
write
public void write(byte[] buf, int offset, int len)Writes the specified bytes into the underlying blocked byte array.- Overrides:
writein classjava.io.OutputStream- Parameters:
buf- source byte arrayoffset- index of the first byte to writelen- the number of bytes to write
-
close
public void close()
Closes the stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream
-
-