public class SeekableByteArrayOutputStream extends ByteArrayOutputStream
SeekableByteArrayOutputStream.buf, count| Constructor and Description |
|---|
SeekableByteArrayOutputStream()
Creates a new byte array output stream.
|
SeekableByteArrayOutputStream(byte[] buf)
Creates a new byte array output stream, which reuses the supplied buffer.
|
SeekableByteArrayOutputStream(int size)
Creates a new byte array output stream, with a buffer capacity of
the specified size, in bytes.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBuffer()
Returns the underlying byte buffer.
|
long |
getStreamPosition()
Returns the current byte position of the stream.
|
void |
reset()
Resets the
count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. |
void |
seek(long pos)
Sets the current stream position to the desired location.
|
void |
toOutputStream(OutputStream out)
Writes the contents of the byte array into the specified output
stream.
|
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array
starting at offset off to this byte array output stream. |
void |
write(int b)
Writes the specified byte to this byte array output stream.
|
close, size, toByteArray, toString, toString, toString, writeToflush, writepublic SeekableByteArrayOutputStream()
public SeekableByteArrayOutputStream(int size)
size - the initial size.IllegalArgumentException - if size is negative.public SeekableByteArrayOutputStream(byte[] buf)
public void write(int b)
write in class ByteArrayOutputStreamb - the byte to be written.public void write(byte[] b,
int off,
int len)
len bytes from the specified byte array
starting at offset off to this byte array output stream.write in class ByteArrayOutputStreamb - the data.off - the start offset in the data.len - the number of bytes to write.public void reset()
count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. The output stream can be used again,
reusing the already allocated buffer space.reset in class ByteArrayOutputStreamByteArrayInputStream.countpublic void seek(long pos)
throws IOException
An IndexOutOfBoundsException will be thrown if
pos is smaller than the flushed position (as
returned by getflushedPosition).
It is legal to seek past the end of the file; an
EOFException will be thrown only if a read is
performed.
pos - a long containing the desired file
pointer position.IndexOutOfBoundsException - if pos is smaller
than the flushed position.IOException - if any other I/O error occurs.public long getStreamPosition()
throws IOException
IOException - if an I/O error occurs.public void toOutputStream(OutputStream out) throws IOException
out - IOExceptionpublic byte[] getBuffer()
Copyright © 2014. All Rights Reserved.