|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
com.twelvemonkeys.io.LittleEndianDataOutputStream
public class LittleEndianDataOutputStream
A little endian output stream writes primitive Java numbers and characters to an output stream in a little endian format.
The standardjava.io.DataOutputStream class which this class
imitates uses big endian integers.
Warning:
The DataInput and DataOutput interfaces
specifies big endian byte order in their documentation.
This means that this class is, strictly speaking, not a proper
implementation. However, I don't see a reason for the these interfaces to
specify the byte order of their underlying representations.
LittleEndianRandomAccessFile,
DataOutputStream,
DataInput,
DataOutput| Field Summary | |
|---|---|
protected int |
bytesWritten
The number of bytes written so far to the little endian output stream. |
| Fields inherited from class java.io.FilterOutputStream |
|---|
out |
| Constructor Summary | |
|---|---|
LittleEndianDataOutputStream(java.io.OutputStream pStream)
Creates a new little endian output stream and chains it to the output stream specified by the pStream argument. |
|
| Method Summary | |
|---|---|
int |
size()
Returns the number of bytes written to this little endian output stream. |
void |
write(byte[] pBytes,
int pOffset,
int pLength)
Writes pLength bytes from the specified byte array
starting at pOffset to the underlying output stream. |
void |
write(int pByte)
Writes the specified byte value to the underlying output stream. |
void |
writeBoolean(boolean pBoolean)
Writes a boolean to the underlying output stream as
a single byte. |
void |
writeByte(int pByte)
Writes out a byte to the underlying output stream |
void |
writeBytes(java.lang.String pString)
Writes a string to the underlying output stream as a sequence of bytes. |
void |
writeChar(int pChar)
Writes a two byte char to the underlying output stream
in little endian order, low byte first. |
void |
writeChars(java.lang.String pString)
Writes a string to the underlying output stream as a sequence of characters. |
void |
writeDouble(double d)
Writes an 8 byte Java double to the underlying output stream in little endian order. |
void |
writeFloat(float f)
Writes a 4 byte Java float to the underlying output stream in little endian order. |
void |
writeInt(int pInt)
Writes a four-byte int to the underlying output stream
in little endian order, low byte first, high byte last |
void |
writeLong(long pLong)
Writes an eight-byte long to the underlying output stream
in little endian order, low byte first, high byte last |
void |
writeShort(int pShort)
Writes a two byte short to the underlying output stream in
little endian order, low byte first. |
void |
writeUTF(java.lang.String pString)
Writes a string of no more than 65,535 characters to the underlying output stream using UTF-8 encoding. |
| Methods inherited from class java.io.FilterOutputStream |
|---|
close, flush, write |
| 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 |
| Field Detail |
|---|
protected int bytesWritten
| Constructor Detail |
|---|
public LittleEndianDataOutputStream(java.io.OutputStream pStream)
pStream argument.
pStream - the underlying output stream.FilterOutputStream.out| Method Detail |
|---|
public void write(int pByte)
throws java.io.IOException
write in interface java.io.DataOutputwrite in class java.io.FilterOutputStreampByte - the byte value to be written.
java.io.IOException - if the underlying stream throws an IOException.
public void write(byte[] pBytes,
int pOffset,
int pLength)
throws java.io.IOException
pLength bytes from the specified byte array
starting at pOffset to the underlying output stream.
write in interface java.io.DataOutputwrite in class java.io.FilterOutputStreampBytes - the data.pOffset - the start offset in the data.pLength - the number of bytes to write.
java.io.IOException - if the underlying stream throws an IOException.
public void writeBoolean(boolean pBoolean)
throws java.io.IOException
boolean to the underlying output stream as
a single byte. If the argument is true, the byte value 1 is written.
If the argument is false, the byte value 0 in written.
writeBoolean in interface java.io.DataOutputpBoolean - the boolean value to be written.
java.io.IOException - if the underlying stream throws an IOException.
public void writeByte(int pByte)
throws java.io.IOException
byte to the underlying output stream
writeByte in interface java.io.DataOutputpByte - the byte value to be written.
java.io.IOException - if the underlying stream throws an IOException.
public void writeShort(int pShort)
throws java.io.IOException
short to the underlying output stream in
little endian order, low byte first.
writeShort in interface java.io.DataOutputpShort - the short to be written.
java.io.IOException - if the underlying stream throws an IOException.
public void writeChar(int pChar)
throws java.io.IOException
char to the underlying output stream
in little endian order, low byte first.
writeChar in interface java.io.DataOutputpChar - the char value to be written.
java.io.IOException - if the underlying stream throws an IOException.
public void writeInt(int pInt)
throws java.io.IOException
int to the underlying output stream
in little endian order, low byte first, high byte last
writeInt in interface java.io.DataOutputpInt - the int to be written.
java.io.IOException - if the underlying stream throws an IOException.
public void writeLong(long pLong)
throws java.io.IOException
long to the underlying output stream
in little endian order, low byte first, high byte last
writeLong in interface java.io.DataOutputpLong - the long to be written.
java.io.IOException - if the underlying stream throws an IOException.
public final void writeFloat(float f)
throws java.io.IOException
writeFloat in interface java.io.DataOutputf - the float value to be written.
java.io.IOException - if an I/O error occurs.
public final void writeDouble(double d)
throws java.io.IOException
writeDouble in interface java.io.DataOutputd - the double value to be written.
java.io.IOException - if an I/O error occurs.
public void writeBytes(java.lang.String pString)
throws java.io.IOException
writeByte(int) method.
writeBytes in interface java.io.DataOutputpString - the String value to be written.
java.io.IOException - if the underlying stream throws an IOException.writeByte(int),
FilterOutputStream.out
public void writeChars(java.lang.String pString)
throws java.io.IOException
writeChar method.
writeChars in interface java.io.DataOutputpString - a String value to be written.
java.io.IOException - if the underlying stream throws an IOException.writeChar(int),
FilterOutputStream.out
public void writeUTF(java.lang.String pString)
throws java.io.IOException
writeUTF in interface java.io.DataOutputpString - the string to be written.
java.io.UTFDataFormatException - if the string is longer than
65,535 characters.
java.io.IOException - if the underlying stream throws an IOException.public int size()
written field.bytesWritten
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||