Package mil.nga.sf.util
Class ByteWriter
- java.lang.Object
-
- mil.nga.sf.util.ByteWriter
-
public class ByteWriter extends Object
Write a byte array- Author:
- osbornb
-
-
Field Summary
Fields Modifier and Type Field Description static ByteOrderDEFAULT_BYTE_ORDERDefault write byte order
-
Constructor Summary
Constructors Constructor Description ByteWriter()ConstructorByteWriter(OutputStream outputStream)ConstructorByteWriter(OutputStream outputStream, ByteOrder byteOrder)ConstructorByteWriter(ByteOrder byteOrder)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the byte writerByteArrayOutputStreamgetByteArrayOutputStream()Get the output streamByteOrdergetByteOrder()Get the byte orderbyte[]getBytes()Get the written bytesOutputStreamgetOutputStream()Get the output streamvoidsetByteOrder(ByteOrder byteOrder)Set the byte orderintsize()Get the current size in bytes writtenvoidwriteByte(byte value)Write a bytevoidwriteDouble(double value)Write a doublevoidwriteInt(int value)Write an integervoidwriteString(String value)Write a String
-
-
-
Field Detail
-
DEFAULT_BYTE_ORDER
public static final ByteOrder DEFAULT_BYTE_ORDER
Default write byte order- Since:
- 2.0.3
-
-
Constructor Detail
-
ByteWriter
public ByteWriter()
Constructor
-
ByteWriter
public ByteWriter(OutputStream outputStream)
Constructor- Parameters:
outputStream- output stream- Since:
- 2.0.3
-
ByteWriter
public ByteWriter(ByteOrder byteOrder)
Constructor- Parameters:
byteOrder- byte order- Since:
- 2.0.3
-
ByteWriter
public ByteWriter(OutputStream outputStream, ByteOrder byteOrder)
Constructor- Parameters:
outputStream- output streambyteOrder- byte order- Since:
- 2.0.3
-
-
Method Detail
-
getOutputStream
public OutputStream getOutputStream()
Get the output stream- Returns:
- output stream
- Since:
- 2.0.3
-
getByteArrayOutputStream
public ByteArrayOutputStream getByteArrayOutputStream()
Get the output stream- Returns:
- output stream
- Since:
- 2.0.3
-
close
public void close()
Close the byte writer
-
getByteOrder
public ByteOrder getByteOrder()
Get the byte order- Returns:
- byte order
-
setByteOrder
public void setByteOrder(ByteOrder byteOrder)
Set the byte order- Parameters:
byteOrder- byte order
-
getBytes
public byte[] getBytes()
Get the written bytes- Returns:
- written bytes
-
size
public int size()
Get the current size in bytes written- Returns:
- bytes written
-
writeString
public void writeString(String value) throws IOException
Write a String- Parameters:
value- string value- Throws:
IOException- upon error
-
writeByte
public void writeByte(byte value) throws IOExceptionWrite a byte- Parameters:
value- byte- Throws:
IOException- upon error
-
writeInt
public void writeInt(int value) throws IOExceptionWrite an integer- Parameters:
value- int value- Throws:
IOException- upon error
-
writeDouble
public void writeDouble(double value) throws IOExceptionWrite a double- Parameters:
value- double- Throws:
IOException- upon error
-
-