public class UnsafeByteArrayOutputStream extends com.esotericsoftware.kryo.io.Output implements ExtendedDataOutput
Constructor and Description |
---|
UnsafeByteArrayOutputStream()
Constructor
|
UnsafeByteArrayOutputStream(byte[] buf)
Constructor to take in a buffer
|
UnsafeByteArrayOutputStream(byte[] buf,
int pos)
Constructor to take in a buffer with a given position into that buffer
|
UnsafeByteArrayOutputStream(int size)
Constructor
|
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
|
protected boolean |
require(int size)
Ensure that this buffer has enough remaining space to add the size.
|
void |
reset()
Clears the buffer
|
void |
skipBytes(int bytesToSkip)
Skip some number of bytes.
|
byte[] |
toByteArray()
Copies the internal byte array
|
byte[] |
toByteArray(int offset,
int length)
Return a copy of slice of byte array
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeBytes(String s) |
void |
writeChar(char v) |
void |
writeChar(int v) |
void |
writeChars(String s) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
void |
writeInt(int pos,
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) |
clear, close, flush, getBuffer, getOutputStream, intLength, longLength, position, setBuffer, setBuffer, setOutputStream, setPosition, toBytes, total, writeAscii, writeByte, writeBytes, writeBytes, writeChars, writeDouble, writeDoubles, writeFloat, writeFloats, writeInt, writeInts, writeInts, writeLong, writeLongs, writeLongs, writeShorts, writeString, writeString, writeVarInt, writeVarLong
public UnsafeByteArrayOutputStream()
public UnsafeByteArrayOutputStream(int size)
size
- Initial size of the underlying byte arraypublic UnsafeByteArrayOutputStream(byte[] buf)
buf
- Buffer to start with, or if null, create own bufferpublic UnsafeByteArrayOutputStream(byte[] buf, int pos)
buf
- Buffer to start withpos
- Position to write at the bufferprotected boolean require(int size)
require
in class com.esotericsoftware.kryo.io.Output
size
- Size to addpublic byte[] getByteArray()
ExtendedDataOutput
getByteArray
in interface ExtendedDataOutput
public byte[] toByteArray()
ExtendedDataOutput
toByteArray
in interface ExtendedDataOutput
public byte[] toByteArray(int offset, int length)
ExtendedDataOutput
toByteArray
in interface ExtendedDataOutput
offset
- offset of arraylength
- length of slicepublic void reset()
ExtendedDataOutput
reset
in interface ExtendedDataOutput
public int getPos()
ExtendedDataOutput
getPos
in interface ExtendedDataOutput
public void write(int b)
write
in interface DataOutput
write
in class com.esotericsoftware.kryo.io.Output
public void write(byte[] b)
write
in interface DataOutput
write
in class com.esotericsoftware.kryo.io.Output
public void write(byte[] b, int off, int len)
write
in interface DataOutput
write
in class com.esotericsoftware.kryo.io.Output
public void writeBoolean(boolean v)
writeBoolean
in interface DataOutput
writeBoolean
in class com.esotericsoftware.kryo.io.Output
public void writeByte(int v)
writeByte
in interface DataOutput
writeByte
in class com.esotericsoftware.kryo.io.Output
public void writeShort(int v)
writeShort
in interface DataOutput
writeShort
in class com.esotericsoftware.kryo.io.Output
public void writeChar(int v) throws IOException
writeChar
in interface DataOutput
IOException
public void writeChar(char v)
writeChar
in class com.esotericsoftware.kryo.io.Output
public void writeInt(int v)
writeInt
in interface DataOutput
writeInt
in class com.esotericsoftware.kryo.io.Output
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 pos, int value)
ExtendedDataOutput
writeInt
in interface ExtendedDataOutput
pos
- Byte position in the output streamvalue
- Value to writepublic void writeLong(long v)
writeLong
in interface DataOutput
writeLong
in class com.esotericsoftware.kryo.io.Output
public void writeFloat(float v)
writeFloat
in interface DataOutput
writeFloat
in class com.esotericsoftware.kryo.io.Output
public void writeDouble(double v)
writeDouble
in interface DataOutput
writeDouble
in class com.esotericsoftware.kryo.io.Output
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
Copyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.