Class LittleEndianDataOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.google.common.io.LittleEndianDataOutputStream
- All Implemented Interfaces:
Closeable
,DataOutput
,Flushable
,AutoCloseable
@GwtIncompatible
public final class LittleEndianDataOutputStream
extends FilterOutputStream
implements DataOutput
An implementation of
DataOutput
that uses little-endian byte ordering for writing
char
, short
, int
, float
, double
, and long
values.
Note: This class intentionally violates the specification of its supertype
DataOutput
, which explicitly requires big-endian byte order.
- Since:
- 8.0
- Author:
- Chris Nokleberg, Keith Bottner
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorDescriptionCreates aLittleEndianDataOutputStream
that wraps the given stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
write
(byte[] b, int off, int len) void
writeBoolean
(boolean v) void
writeByte
(int v) void
writeBytes
(String s) Deprecated.void
writeChar
(int v) Writes a char as specified byDataOutputStream.writeChar(int)
, except using little-endian byte order.void
writeChars
(String s) Writes aString
as specified byDataOutputStream.writeChars(String)
, except each character is written using little-endian byte order.void
writeDouble
(double v) Writes adouble
as specified byDataOutputStream.writeDouble(double)
, except using little-endian byte order.void
writeFloat
(float v) Writes afloat
as specified byDataOutputStream.writeFloat(float)
, except using little-endian byte order.void
writeInt
(int v) Writes anint
as specified byDataOutputStream.writeInt(int)
, except using little-endian byte order.void
writeLong
(long v) Writes along
as specified byDataOutputStream.writeLong(long)
, except using little-endian byte order.void
writeShort
(int v) Writes ashort
as specified byDataOutputStream.writeShort(int)
, except using little-endian byte order.void
Methods inherited from class java.io.FilterOutputStream
flush, write, 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, write
-
Constructor Details
-
LittleEndianDataOutputStream
Creates aLittleEndianDataOutputStream
that wraps the given stream.- Parameters:
out
- the stream to delegate to
-
-
Method Details
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
writeBoolean
- Specified by:
writeBoolean
in interfaceDataOutput
- Throws:
IOException
-
writeByte
- Specified by:
writeByte
in interfaceDataOutput
- Throws:
IOException
-
writeBytes
Deprecated.The semantics ofwriteBytes(String s)
are considered dangerous. Please usewriteUTF(String s)
,writeChars(String s)
or another write method instead.- Specified by:
writeBytes
in interfaceDataOutput
- Throws:
IOException
-
writeChar
Writes a char as specified byDataOutputStream.writeChar(int)
, except using little-endian byte order.- Specified by:
writeChar
in interfaceDataOutput
- Throws:
IOException
- if an I/O error occurs
-
writeChars
Writes aString
as specified byDataOutputStream.writeChars(String)
, except each character is written using little-endian byte order.- Specified by:
writeChars
in interfaceDataOutput
- Throws:
IOException
- if an I/O error occurs
-
writeDouble
Writes adouble
as specified byDataOutputStream.writeDouble(double)
, except using little-endian byte order.- Specified by:
writeDouble
in interfaceDataOutput
- Throws:
IOException
- if an I/O error occurs
-
writeFloat
Writes afloat
as specified byDataOutputStream.writeFloat(float)
, except using little-endian byte order.- Specified by:
writeFloat
in interfaceDataOutput
- Throws:
IOException
- if an I/O error occurs
-
writeInt
Writes anint
as specified byDataOutputStream.writeInt(int)
, except using little-endian byte order.- Specified by:
writeInt
in interfaceDataOutput
- Throws:
IOException
- if an I/O error occurs
-
writeLong
Writes along
as specified byDataOutputStream.writeLong(long)
, except using little-endian byte order.- Specified by:
writeLong
in interfaceDataOutput
- Throws:
IOException
- if an I/O error occurs
-
writeShort
Writes ashort
as specified byDataOutputStream.writeShort(int)
, except using little-endian byte order.- Specified by:
writeShort
in interfaceDataOutput
- Throws:
IOException
- if an I/O error occurs
-
writeUTF
- Specified by:
writeUTF
in interfaceDataOutput
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
writeBytes(String s)
are considered dangerous.