org.freehep.util.io
Class ByteOrderOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- org.freehep.util.io.CompressableOutputStream
-
- org.freehep.util.io.BitOutputStream
-
- org.freehep.util.io.ByteOrderOutputStream
-
- All Implemented Interfaces:
- java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.lang.AutoCloseable, FinishableOutputStream
- Direct Known Subclasses:
- ByteCountOutputStream
public class ByteOrderOutputStream extends BitOutputStream implements java.io.DataOutput
Class to write bytes and pairs of bytes in both little and big endian order.
-
-
Constructor Summary
Constructors Constructor and Description ByteOrderOutputStream(java.io.OutputStream out)Create a (Big Endian) Byte Order output stream from given streamByteOrderOutputStream(java.io.OutputStream out, boolean littleEndian)Create a Byte Order output stream from the given stream
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description intsize()voidwrite(int b)voidwriteAsciiZString(java.lang.String s)Write an ascii-z (0 terminated c-string).voidwriteBoolean(boolean b)voidwriteByte(byte[] bytes)Writes array of bytesvoidwriteByte(int b)Write a signed byte.voidwriteBytes(java.lang.String s)voidwriteChar(int c)voidwriteChars(java.lang.String s)voidwriteDouble(double d)voidwriteFloat(float f)voidwriteInt(int i)Write a signed integer.voidwriteInt(int[] ints)Write an array of intsvoidwriteLong(long l)voidwriteShort(int s)Write a signed short.voidwriteShort(short[] shorts)Write an array of shorts.voidwriteString(java.lang.String s)Write a string (UTF)voidwriteUnsignedByte(int ub)Write an unsigned byte.voidwriteUnsignedByte(int[] bytes)Write an array of unsigned bytes.voidwriteUnsignedInt(long i)Write an unsigned integer.voidwriteUnsignedInt(long[] ints)Write an array of unsigned intsvoidwriteUnsignedShort(int s)Write an unsigned short.voidwriteUnsignedShort(int[] shorts)Write an array of unsigned shorts.voidwriteUTF(java.lang.String s)static voidwriteUTF(java.lang.String s, java.io.DataOutput dos)Write a UTF string to the data output stream.-
Methods inherited from class org.freehep.util.io.BitOutputStream
byteAlign, close, finish, minBits, minBits, minBits, writeBitFlag, writeFBits, writeSBits, writeUBits
-
Methods inherited from class org.freehep.util.io.CompressableOutputStream
startCompressing, write
-
-
-
-
Constructor Detail
-
ByteOrderOutputStream
public ByteOrderOutputStream(java.io.OutputStream out)
Create a (Big Endian) Byte Order output stream from given stream- Parameters:
out- stream to write to
-
ByteOrderOutputStream
public ByteOrderOutputStream(java.io.OutputStream out, boolean littleEndian)Create a Byte Order output stream from the given stream- Parameters:
out- stream to write tolittleEndian- true if stream should be little endian
-
-
Method Detail
-
size
public int size() throws java.io.IOException- Returns:
- number of written bytes
- Throws:
java.io.IOException- if write fails FIXME, should this throw an exception ?
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Overrides:
writein classBitOutputStream- Throws:
java.io.IOException
-
writeBoolean
public void writeBoolean(boolean b) throws java.io.IOException- Specified by:
writeBooleanin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChar
public void writeChar(int c) throws java.io.IOException- Specified by:
writeCharin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeByte
public void writeByte(int b) throws java.io.IOExceptionWrite a signed byte.- Specified by:
writeBytein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeByte
public void writeByte(byte[] bytes) throws java.io.IOExceptionWrites array of bytes- Parameters:
bytes- byte array to be written- Throws:
java.io.IOException- if write fails
-
writeUnsignedByte
public void writeUnsignedByte(int ub) throws java.io.IOExceptionWrite an unsigned byte.- Parameters:
ub- byte to write- Throws:
java.io.IOException- if write fails
-
writeUnsignedByte
public void writeUnsignedByte(int[] bytes) throws java.io.IOExceptionWrite an array of unsigned bytes.- Parameters:
bytes- int array to write as bytes- Throws:
java.io.IOException- if write fails
-
writeShort
public void writeShort(int s) throws java.io.IOExceptionWrite a signed short.- Specified by:
writeShortin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeShort
public void writeShort(short[] shorts) throws java.io.IOExceptionWrite an array of shorts.- Parameters:
shorts- short array to write- Throws:
java.io.IOException- if write fails
-
writeUnsignedShort
public void writeUnsignedShort(int s) throws java.io.IOExceptionWrite an unsigned short.- Parameters:
s- int to write as unsigned short- Throws:
java.io.IOException- if write fails
-
writeUnsignedShort
public void writeUnsignedShort(int[] shorts) throws java.io.IOExceptionWrite an array of unsigned shorts.- Parameters:
shorts- int array to write as unsigned shorts- Throws:
java.io.IOException- if write fails
-
writeInt
public void writeInt(int i) throws java.io.IOExceptionWrite a signed integer.- Specified by:
writeIntin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeInt
public void writeInt(int[] ints) throws java.io.IOExceptionWrite an array of ints- Parameters:
ints- int array to write- Throws:
java.io.IOException- if write fails
-
writeUnsignedInt
public void writeUnsignedInt(long i) throws java.io.IOExceptionWrite an unsigned integer.- Parameters:
i- long to write as unsigned int- Throws:
java.io.IOException- if write fails
-
writeUnsignedInt
public void writeUnsignedInt(long[] ints) throws java.io.IOExceptionWrite an array of unsigned ints- Parameters:
ints- long array to write as unsigned ints- Throws:
java.io.IOException- if write fails
-
writeLong
public void writeLong(long l) throws java.io.IOException- Specified by:
writeLongin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(float f) throws java.io.IOException- Specified by:
writeFloatin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(double d) throws java.io.IOException- Specified by:
writeDoublein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.lang.String s) throws java.io.IOException- Specified by:
writeBytesin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChars
public void writeChars(java.lang.String s) throws java.io.IOException- Specified by:
writeCharsin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeString
public void writeString(java.lang.String s) throws java.io.IOExceptionWrite a string (UTF)- Parameters:
s- string to write- Throws:
java.io.IOException- if write fails
-
writeUTF
public void writeUTF(java.lang.String s) throws java.io.IOException- Specified by:
writeUTFin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeAsciiZString
public void writeAsciiZString(java.lang.String s) throws java.io.IOExceptionWrite an ascii-z (0 terminated c-string).- Parameters:
s- string to write- Throws:
java.io.IOException- if write fails
-
writeUTF
public static void writeUTF(java.lang.String s, java.io.DataOutput dos) throws java.io.IOExceptionWrite a UTF string to the data output stream. This method should have been in DataOutputStream, but is not visible.- Parameters:
s- string to writedos- stream to write to- Throws:
java.io.IOException- if write fails
-
-
DMelt 3.0 © DataMelt by jWork.ORG