Package com.saicone.nbt.io
Class NetworkDataOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.saicone.nbt.io.ReverseDataOutputStream
com.saicone.nbt.io.NetworkDataOutputStream
- All Implemented Interfaces:
Closeable
,DataOutput
,Flushable
,AutoCloseable
A network data output stream do the same functionality as
This implementation aims to be same as Minecraft Bedrock network data encoding.
ReverseDataOutputStream
but writes
integers as VarInt32, longs as VarInt64 and String size as unsigned VarInt32.This implementation aims to be same as Minecraft Bedrock network data encoding.
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a network data output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
writeInt
(int v) void
writeLong
(long v) void
writeUnsignedVarInt32
(int v) Write an integer as VarInt32 using Andrew Steinborn blended method with a little optimization.void
writeUnsignedVarInt64
(long v) Write an long as VarInt64 using Andrew Steinborn blended method extended for long values with a little optimization.void
Methods inherited from class com.saicone.nbt.io.ReverseDataOutputStream
close, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeShort
Methods inherited from class java.io.FilterOutputStream
flush, write
Methods inherited from class java.io.OutputStream
nullOutputStream
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.io.DataOutput
write
-
Constructor Details
-
NetworkDataOutputStream
Constructs a network data output stream.- Parameters:
out
- the delegated output stream to write bytes.
-
-
Method Details
-
writeUnsignedVarInt32
Write an integer as VarInt32 using Andrew Steinborn blended method with a little optimization.- Parameters:
v
- the integer to write.- Throws:
IOException
- if any I/O error occurs.
-
writeUnsignedVarInt64
Write an long as VarInt64 using Andrew Steinborn blended method extended for long values with a little optimization.- Parameters:
v
- the long to write.- Throws:
IOException
- if any I/O error occurs.
-
writeInt
- Specified by:
writeInt
in interfaceDataOutput
- Overrides:
writeInt
in classReverseDataOutputStream
- Throws:
IOException
-
writeLong
- Specified by:
writeLong
in interfaceDataOutput
- Overrides:
writeLong
in classReverseDataOutputStream
- Throws:
IOException
-
writeUTF
- Specified by:
writeUTF
in interfaceDataOutput
- Overrides:
writeUTF
in classReverseDataOutputStream
- Throws:
IOException
-