Package mgui.io.util
Class EndianCorrectOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.DataOutputStream
mgui.io.util.EndianCorrectOutputStream
- All Implemented Interfaces:
java.io.Closeable
,java.io.DataOutput
,java.io.Flushable
,java.lang.AutoCloseable
public class EndianCorrectOutputStream
extends java.io.DataOutputStream
EndianCorrectOutputStream extends DataOutputStream; it will optionally flip
bytes to write little endian data correctly.
-
Field Summary
Fields inherited from class java.io.DataOutputStream
written
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
Constructors Constructor Description EndianCorrectOutputStream(java.io.OutputStream os, boolean be)
Constructor for an OutputStream.EndianCorrectOutputStream(java.lang.String filename, boolean be)
Constructor for a disk file. -
Method Summary
Modifier and Type Method Description double
flipDouble(double val)
flipDouble will flip the byte order of a doublefloat
flipFloat(float val)
flipFloat will flip the byte order of a floatint
flipInt(int val)
flipInt will flip the byte order of an intlong
flipLong(long val)
flipLong will flip the byte order of a longshort
flipShort(short val)
flipShort will byte flip a shortvoid
writeDoubleCorrect(double val)
writeDoubleCorrect will write a double to the streamvoid
writeFloatCorrect(float val)
writeFloatCorrect will write a float to the streamvoid
writeIntCorrect(int val)
writeIntCorrect will write an int to the streamvoid
writeLongCorrect(long val)
writeLongCorrect will write a long to the streamvoid
writeShortCorrect(short val)
writeShortCorrect will write a short to the streamMethods inherited from class java.io.DataOutputStream
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
Methods inherited from class java.io.FilterOutputStream
close, 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
-
EndianCorrectOutputStream
public EndianCorrectOutputStream(java.lang.String filename, boolean be) throws java.io.FileNotFoundException, java.lang.SecurityExceptionConstructor for a disk file.- Parameters:
filename
- filename for datafilebe
- -- endian flag: if be (big endian) is false bytes will be flipped on write- Throws:
java.io.FileNotFoundException
java.lang.SecurityException
-
EndianCorrectOutputStream
public EndianCorrectOutputStream(java.io.OutputStream os, boolean be)Constructor for an OutputStream.- Parameters:
is
- OutputStream to write data tobe
- -- endian flag: if be (big endian) is false bytes will be flipped on write- Throws:
java.io.FileNotFoundException
-
-
Method Details
-
writeShortCorrect
public void writeShortCorrect(short val) throws java.io.IOExceptionwriteShortCorrect will write a short to the stream- Throws:
java.io.IOException
-
flipShort
public short flipShort(short val)flipShort will byte flip a short -
writeIntCorrect
public void writeIntCorrect(int val) throws java.io.IOExceptionwriteIntCorrect will write an int to the stream- Throws:
java.io.IOException
-
flipInt
public int flipInt(int val)flipInt will flip the byte order of an int -
writeLongCorrect
public void writeLongCorrect(long val) throws java.io.IOExceptionwriteLongCorrect will write a long to the stream- Throws:
java.io.IOException
-
flipLong
public long flipLong(long val)flipLong will flip the byte order of a long -
writeFloatCorrect
public void writeFloatCorrect(float val) throws java.io.IOExceptionwriteFloatCorrect will write a float to the stream- Throws:
java.io.IOException
-
flipFloat
public float flipFloat(float val) throws java.io.IOExceptionflipFloat will flip the byte order of a float- Throws:
java.io.IOException
-
writeDoubleCorrect
public void writeDoubleCorrect(double val) throws java.io.IOExceptionwriteDoubleCorrect will write a double to the stream- Throws:
java.io.IOException
-
flipDouble
public double flipDouble(double val)flipDouble will flip the byte order of a double
-