Package com.google.common.io
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 ofDataOutputthat uses little-endian byte ordering for writingchar,short,int,float,double, andlongvalues.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
Constructors Constructor Description LittleEndianDataOutputStream(OutputStream out)Creates aLittleEndianDataOutputStreamthat wraps the given stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()voidwrite(byte[] b, int off, int len)voidwriteBoolean(boolean v)voidwriteByte(int v)voidwriteBytes(String s)Deprecated.The semantics ofwriteBytes(String s)are considered dangerous.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.voidwriteUTF(String str)-
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 Detail
-
LittleEndianDataOutputStream
public LittleEndianDataOutputStream(OutputStream out)
Creates aLittleEndianDataOutputStreamthat wraps the given stream.- Parameters:
out- the stream to delegate to
-
-
Method Detail
-
write
public void write(byte[] b, int off, int len) throws IOException
- Specified by:
writein interfaceDataOutput- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
writeBoolean
public void writeBoolean(boolean v) throws IOException
- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeByte
public void writeByte(int v) throws IOException
- Specified by:
writeBytein interfaceDataOutput- Throws:
IOException
-
writeBytes
@Deprecated public void writeBytes(String s) throws IOException
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
public void writeChar(int v) throws IOException
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
public void writeChars(String s) throws IOException
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
public void writeDouble(double v) throws IOException
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
public void writeFloat(float v) throws IOException
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
public void writeInt(int v) throws IOException
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
public void writeLong(long v) throws IOException
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
public void writeShort(int v) throws IOException
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
public void writeUTF(String str) throws IOException
- Specified by:
writeUTFin interfaceDataOutput- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
-