java.io.Closeable
, java.io.Flushable
, java.lang.AutoCloseable
TupleOutput
public class FastOutputStream
extends java.io.OutputStream
This class extends OutputStream
and its write()
methods allow it to be used as a standard output stream. In addition, it
provides writeFast()
methods that are not declared to throw
IOException
. IOException
is never thrown by this
class.
Modifier and Type | Field | Description |
---|---|---|
static int |
DEFAULT_BUMP_SIZE |
The default amount that the buffer is increased when it is full.
|
static int |
DEFAULT_INIT_SIZE |
The default initial size of the buffer if no initialSize parameter is
specified.
|
Constructor | Description |
---|---|
FastOutputStream() |
Creates an output stream with default sizes.
|
FastOutputStream(byte[] buffer) |
Creates an output stream with a given initial buffer and a default
bump size.
|
FastOutputStream(byte[] buffer,
int bumpSize) |
Creates an output stream with a given initial buffer and a given
bump size.
|
FastOutputStream(int initialSize) |
Creates an output stream with a default bump size and a given initial
size.
|
FastOutputStream(int initialSize,
int bumpSize) |
Creates an output stream with a given bump size and initial size.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addSize(int sizeAdded) |
Skip the given number of bytes in the buffer.
|
byte[] |
getBufferBytes() |
Returns the buffer owned by this object.
|
int |
getBufferLength() |
Returns the length used in the internal buffer, i.e., the offset at
which data will be written next.
|
int |
getBufferOffset() |
Returns the offset of the internal buffer.
|
void |
makeSpace(int sizeNeeded) |
Ensure that at least the given number of bytes are available in the
internal buffer.
|
void |
reset() |
|
int |
size() |
|
byte[] |
toByteArray() |
|
java.lang.String |
toString() |
|
java.lang.String |
toString(java.lang.String encoding) |
|
void |
write(byte[] fromBuf) |
|
void |
write(byte[] fromBuf,
int offset,
int length) |
|
void |
write(int b) |
|
void |
writeFast(byte[] fromBuf) |
Equivalent to
write(byte[]) but does not throw
IOException . |
void |
writeFast(byte[] fromBuf,
int offset,
int length) |
Equivalent to
write(byte[],int,int) but does not throw
IOException . |
void |
writeFast(int b) |
Equivalent to
write(int) but does not throw
IOException . |
void |
writeTo(java.io.OutputStream out) |
public static final int DEFAULT_INIT_SIZE
public static final int DEFAULT_BUMP_SIZE
public FastOutputStream()
public FastOutputStream(int initialSize)
initialSize
- the initial size of the buffer.public FastOutputStream(int initialSize, int bumpSize)
initialSize
- the initial size of the buffer.bumpSize
- the amount to increment the buffer.public FastOutputStream(byte[] buffer)
buffer
- the initial buffer; will be owned by this object.public FastOutputStream(byte[] buffer, int bumpSize)
buffer
- the initial buffer; will be owned by this object.bumpSize
- the amount to increment the buffer. If zero (the
default), the current buffer size will be doubled when the buffer is
full.public int size()
public void reset()
public void write(int b)
write
in class java.io.OutputStream
public void write(byte[] fromBuf)
write
in class java.io.OutputStream
public void write(byte[] fromBuf, int offset, int length)
write
in class java.io.OutputStream
public void writeTo(java.io.OutputStream out) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String encoding) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public byte[] toByteArray()
public final void writeFast(int b)
write(int)
but does not throw
IOException
.b
- the byte to write.write(int)
public final void writeFast(byte[] fromBuf)
write(byte[])
but does not throw
IOException
.fromBuf
- the buffer to write.write(byte[])
public final void writeFast(byte[] fromBuf, int offset, int length)
write(byte[],int,int)
but does not throw
IOException
.fromBuf
- the buffer to write.offset
- the start offset in the buffer.length
- the number of bytes to write.write(byte[],int,int)
public byte[] getBufferBytes()
public int getBufferOffset()
public int getBufferLength()
public void makeSpace(int sizeNeeded)
sizeNeeded
- the number of bytes desired.public void addSize(int sizeAdded)
sizeAdded
- number of bytes to skip.Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved.