public class ExtendedByteArrayDataOutput extends ByteArrayOutputStream implements ExtendedDataOutput
buf, count
Constructor and Description |
---|
ExtendedByteArrayDataOutput()
Creates a new byte array output stream.
|
ExtendedByteArrayDataOutput(byte[] buf)
Uses the byte array provided or if null, use a default size
|
ExtendedByteArrayDataOutput(byte[] buf,
int pos)
Uses the byte array provided at the given pos
|
ExtendedByteArrayDataOutput(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 |
---|---|
void |
ensureWritable(int minSize)
Ensure that backing byte structure has at least minSize
additional bytes
|
byte[] |
getByteArray()
Get the internal byte array (if possible), read-only
|
int |
getPos()
Get the position in the output stream
|
void |
skipBytes(int bytesToSkip)
Skip some number of bytes.
|
byte[] |
toByteArray(int offset,
int length)
Return a copy of slice of byte array
|
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeBytes(String s) |
void |
writeChar(int v) |
void |
writeChars(String s) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
void |
writeInt(int position,
int value)
In order to write a size as a first part of an data output, it is
useful to be able to write an int at an arbitrary location in the stream
|
void |
writeLong(long v) |
void |
writeShort(int v) |
void |
writeUTF(String s) |
close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo
flush, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
reset, toByteArray
write, write, write
public ExtendedByteArrayDataOutput(byte[] buf)
buf
- Buffer to usepublic ExtendedByteArrayDataOutput(byte[] buf, int pos)
buf
- Buffer to usepos
- Position in the buffer to start writing frompublic ExtendedByteArrayDataOutput()
public ExtendedByteArrayDataOutput(int size)
size
- the initial size.IllegalArgumentException
- if size is negative.public void writeBoolean(boolean v) throws IOException
writeBoolean
in interface DataOutput
IOException
public void writeByte(int v) throws IOException
writeByte
in interface DataOutput
IOException
public void writeShort(int v) throws IOException
writeShort
in interface DataOutput
IOException
public void writeChar(int v) throws IOException
writeChar
in interface DataOutput
IOException
public void writeInt(int v) throws IOException
writeInt
in interface DataOutput
IOException
public void writeLong(long v) throws IOException
writeLong
in interface DataOutput
IOException
public void writeFloat(float v) throws IOException
writeFloat
in interface DataOutput
IOException
public void writeDouble(double v) throws IOException
writeDouble
in interface DataOutput
IOException
public void writeBytes(String s) throws IOException
writeBytes
in interface DataOutput
IOException
public void writeChars(String s) throws IOException
writeChars
in interface DataOutput
IOException
public void writeUTF(String s) throws IOException
writeUTF
in interface DataOutput
IOException
public void ensureWritable(int minSize)
ExtendedDataOutput
ensureWritable
in interface ExtendedDataOutput
minSize
- additional size requiredpublic void skipBytes(int bytesToSkip)
ExtendedDataOutput
skipBytes
in interface ExtendedDataOutput
bytesToSkip
- Number of bytes to skippublic void writeInt(int position, int value)
ExtendedDataOutput
writeInt
in interface ExtendedDataOutput
position
- Byte position in the output streamvalue
- Value to writepublic byte[] toByteArray(int offset, int length)
ExtendedDataOutput
toByteArray
in interface ExtendedDataOutput
offset
- offset of arraylength
- length of slicepublic byte[] getByteArray()
ExtendedDataOutput
getByteArray
in interface ExtendedDataOutput
public int getPos()
ExtendedDataOutput
getPos
in interface ExtendedDataOutput
Copyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.