Class DataWriterBigEndian
-
- All Implemented Interfaces:
public class DataWriterBigEndian
-
-
Constructor Summary
Constructors Constructor Description DataWriterBigEndian()Creates a new data array output stream. DataWriterBigEndian(int capacity)Creates a new data array output stream, with a buffer capacity of the specified size, in bytes.
-
Method Summary
Modifier and Type Method Description synchronized voidreset()Resets the countfield of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded.voidstorePosition()Save current position. voidrestorePosition()voidmoveTo(int index)synchronized voidwrite(int b)Writes the specified byte to this byte array output stream. synchronized voidwrite(Array<byte> b)synchronized voidwrite(Array<byte> b, int off, int len)Writes lenbytes from the specified byte array starting at offsetoffto this byte array output stream.final voidwriteByte(byte b)Write single byte to stream. final voidwriteBoolean(boolean v)Writes a booleanto the underlying output stream as a 1-byte value.final voidwriteShort(int v)Writes a shortto the underlying output stream as two bytes, high byte first.final voidwriteInt(int v)Writes an intto the underlying output stream as four bytes, high byte first.final voidwriteLong(long v)Writes a longto the underlying output stream as eight bytes, high byte first.final voidwriteFloat(float v)Converts the float argument to an intusing thefloatToIntBitsmethod in classFloat, and then writes thatintvalue to the underlying output stream as a 4-byte quantity, high byte first.final voidwriteDouble(double v)Converts the double argument to a longusing thedoubleToLongBitsmethod in classDouble, and then writes thatlongvalue to the underlying output stream as an 8-byte quantity, high byte first.final voidwriteString(String string)final voidwriteStringDos(String string)final voidwriteStorable(Storable obj)voidwriteListString(List<String> objs)voidwriteListStorable(List<out Storable> objs)synchronized voidwriteTo(OutputStream out)Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count).synchronized Array<byte>toByteArray()Creates a newly allocated byte array. synchronized intsize()Returns the current size of the buffer. -
-
Method Detail
-
reset
synchronized void reset()
Resets the
countfield 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.
-
storePosition
void storePosition()
Save current position.
-
restorePosition
void restorePosition()
-
moveTo
void moveTo(int index)
-
write
synchronized void write(int b)
Writes the specified byte to this byte array output stream.
- Parameters:
b- the byte to be written.
-
write
synchronized void write(Array<byte> b, int off, int len)
Writes
lenbytes from the specified byte array starting at offsetoffto this byte array output stream.- Parameters:
b- the data.off- the start offset in the data.len- the number of bytes to write.
-
writeByte
final void writeByte(byte b)
Write single byte to stream.
-
writeBoolean
final void writeBoolean(boolean v)
Writes a
booleanto the underlying output stream as a 1-byte value. The valuetrueis written out as the value(byte)1; the valuefalseis written out as the value(byte)0. If no exception is thrown, the counterwrittenis incremented by1.- Parameters:
v- abooleanvalue to be written.
-
writeShort
final void writeShort(int v)
Writes a
shortto the underlying output stream as two bytes, high byte first. If no exception is thrown, the counterwrittenis incremented by2.- Parameters:
v- ashortto be written.
-
writeInt
final void writeInt(int v)
Writes an
intto the underlying output stream as four bytes, high byte first. If no exception is thrown, the counterwrittenis incremented by4.- Parameters:
v- anintto be written.
-
writeLong
final void writeLong(long v)
Writes a
longto the underlying output stream as eight bytes, high byte first. In no exception is thrown, the counterwrittenis incremented by8.- Parameters:
v- alongto be written.
-
writeFloat
final void writeFloat(float v)
Converts the float argument to an
intusing thefloatToIntBitsmethod in classFloat, and then writes thatintvalue to the underlying output stream as a 4-byte quantity, high byte first. If no exception is thrown, the counterwrittenis incremented by4.- Parameters:
v- afloatvalue to be written.
-
writeDouble
final void writeDouble(double v)
Converts the double argument to a
longusing thedoubleToLongBitsmethod in classDouble, and then writes thatlongvalue to the underlying output stream as an 8-byte quantity, high byte first. If no exception is thrown, the counterwrittenis incremented by8.- Parameters:
v- adoublevalue to be written.
-
writeString
final void writeString(String string)
-
writeStringDos
@Deprecated() final void writeStringDos(String string)
-
writeStorable
final void writeStorable(Storable obj)
-
writeListString
void writeListString(List<String> objs)
-
writeListStorable
void writeListStorable(List<out Storable> objs)
-
writeTo
synchronized void writeTo(OutputStream out)
Writes the complete contents of this byte array output stream to the specified output stream argument, as if by calling the output stream's write method using
out.write(buf, 0, count).- Parameters:
out- the output stream to which to write the data.
-
toByteArray
synchronized Array<byte> toByteArray()
Creates a newly allocated byte array. Its size is the current size of this output stream and the valid contents of the buffer have been copied into it.
-
size
synchronized int size()
Returns the current size of the buffer.
-
-
-
-