public final class GrowableByteArrayDataOutput extends DataOutput implements Accountable
DataOutput
that can be used to build a byte[].NULL_ACCOUNTABLE
Constructor and Description |
---|
GrowableByteArrayDataOutput(int cp)
Create a
GrowableByteArrayDataOutput with the given initial capacity. |
Modifier and Type | Method and Description |
---|---|
byte[] |
getBytes() |
int |
getPosition() |
long |
ramBytesUsed()
Return the memory usage of this object in bytes.
|
void |
reset() |
void |
writeByte(byte b)
Writes a single byte.
|
void |
writeBytes(byte[] b,
int off,
int len)
Writes an array of bytes.
|
void |
writeString(String string)
Writes a string.
|
copyBytes, writeBytes, writeInt, writeLong, writeMapOfStrings, writeSetOfStrings, writeShort, writeVInt, writeVLong, writeZInt, writeZLong
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getChildResources
public GrowableByteArrayDataOutput(int cp)
GrowableByteArrayDataOutput
with the given initial capacity.public void writeByte(byte b)
DataOutput
The most primitive data type is an eight-bit byte. Files are accessed as sequences of bytes. All other data types are defined as sequences of bytes, so file formats are byte-order independent.
writeByte
in class DataOutput
DataInput.readByte()
public void writeBytes(byte[] b, int off, int len)
DataOutput
writeBytes
in class DataOutput
b
- the bytes to writeoff
- the offset in the byte arraylen
- the number of bytes to writeDataInput.readBytes(byte[],int,int)
public void writeString(String string) throws IOException
DataOutput
Writes strings as UTF-8 encoded bytes. First the length, in bytes, is
written as a VInt
, followed by the bytes.
writeString
in class DataOutput
IOException
DataInput.readString()
public byte[] getBytes()
public int getPosition()
public void reset()
public long ramBytesUsed()
Accountable
ramBytesUsed
in interface Accountable
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.