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
ConstructorsConstructorDescriptionCreates aLittleEndianDataOutputStreamthat wraps the given stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidwrite(byte[] b, int off, int len) voidwriteBoolean(boolean v) voidwriteByte(int v) voidwriteBytes(String s) Deprecated.voidwriteChar(int v) Writes a char as specified byDataOutputStream.writeChar(int), except using little-endian byte order.voidwriteChars(String s) Writes aStringas specified byDataOutputStream.writeChars(String), except each character is written using little-endian byte order.voidwriteDouble(double v) Writes adoubleas specified byDataOutputStream.writeDouble(double), except using little-endian byte order.voidwriteFloat(float v) Writes afloatas specified byDataOutputStream.writeFloat(float), except using little-endian byte order.voidwriteInt(int v) Writes anintas specified byDataOutputStream.writeInt(int), except using little-endian byte order.voidwriteLong(long v) Writes alongas specified byDataOutputStream.writeLong(long), except using little-endian byte order.voidwriteShort(int v) Writes ashortas specified byDataOutputStream.writeShort(int), except using little-endian byte order.voidMethods inherited from class java.io.FilterOutputStream
flush, write, writeMethods inherited from class java.io.OutputStream
nullOutputStreamMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.io.DataOutput
write, write
-
Constructor Details
-
LittleEndianDataOutputStream
Creates aLittleEndianDataOutputStreamthat wraps the given stream.- Parameters:
out- the stream to delegate to
-
-
Method Details
-
write
- Specified by:
writein interfaceDataOutput- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
writeBoolean
- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeByte
- Specified by:
writeBytein 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:
writeBytesin interfaceDataOutput- Throws:
IOException
-
writeChar
Writes a char as specified byDataOutputStream.writeChar(int), except using little-endian byte order.- Specified by:
writeCharin interfaceDataOutput- Throws:
IOException- if an I/O error occurs
-
writeChars
Writes aStringas specified byDataOutputStream.writeChars(String), except each character is written using little-endian byte order.- Specified by:
writeCharsin interfaceDataOutput- Throws:
IOException- if an I/O error occurs
-
writeDouble
Writes adoubleas specified byDataOutputStream.writeDouble(double), except using little-endian byte order.- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException- if an I/O error occurs
-
writeFloat
Writes afloatas specified byDataOutputStream.writeFloat(float), except using little-endian byte order.- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException- if an I/O error occurs
-
writeInt
Writes anintas specified byDataOutputStream.writeInt(int), except using little-endian byte order.- Specified by:
writeIntin interfaceDataOutput- Throws:
IOException- if an I/O error occurs
-
writeLong
Writes alongas specified byDataOutputStream.writeLong(long), except using little-endian byte order.- Specified by:
writeLongin interfaceDataOutput- Throws:
IOException- if an I/O error occurs
-
writeShort
Writes ashortas specified byDataOutputStream.writeShort(int), except using little-endian byte order.- Specified by:
writeShortin interfaceDataOutput- Throws:
IOException- if an I/O error occurs
-
writeUTF
- Specified by:
writeUTFin interfaceDataOutput- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
writeBytes(String s)are considered dangerous.