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:
Closeable
,Flushable
,AutoCloseable
Output stream writing bytes into an underlying blocked byte array.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
The current position of the stream.private BlockedByteArray
The underlying destination. -
Constructor Summary
ConstructorsConstructorDescriptionBlockedByteArrayOutputStream
(BlockedByteArray src, long pos) Creates a new stream writing data into the specified blocked byte array. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the stream.(package private) long
Returns the current position.(package private) void
setPosition
(long newPos) Sets the position.void
write
(byte[] buf, int offset, int len) Writes the specified bytes into the underlying blocked byte array.void
write
(int b) Writes the single byte into the underlying blocked byte array.Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Field Details
-
src
The underlying destination. Set tonull
when closed. -
pos
private long posThe current position of the stream.
-
-
Constructor Details
-
BlockedByteArrayOutputStream
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 Details
-
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:
write
in classOutputStream
- 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:
write
in classOutputStream
- 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
-