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 ByteOrder
DEFAULT_BYTE_ORDER
Default 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 void
close()
Close the byte writerByteArrayOutputStream
getByteArrayOutputStream()
Get the output streamByteOrder
getByteOrder()
Get the byte orderbyte[]
getBytes()
Get the written bytesOutputStream
getOutputStream()
Get the output streamvoid
setByteOrder(ByteOrder byteOrder)
Set the byte orderint
size()
Get the current size in bytes writtenvoid
writeByte(byte value)
Write a bytevoid
writeDouble(double value)
Write a doublevoid
writeInt(int value)
Write an integervoid
writeString(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 IOException
Write a byte- Parameters:
value
- byte- Throws:
IOException
- upon error
-
writeInt
public void writeInt(int value) throws IOException
Write an integer- Parameters:
value
- int value- Throws:
IOException
- upon error
-
writeDouble
public void writeDouble(double value) throws IOException
Write a double- Parameters:
value
- double- Throws:
IOException
- upon error
-
-