public class RandomAccessOutputStream extends OutputStream implements DataOutput, Closeable
Modifier and Type | Field and Description |
---|---|
private int |
currentBit |
private int |
currentByte |
private boolean |
dirtyByte |
private IRandomAccess |
outputFile |
Constructor and Description |
---|
RandomAccessOutputStream(byte[] array)
Constructs a random access stream around the given byte array.
|
RandomAccessOutputStream(IRandomAccess handle)
Constructs a random access stream around the given handle.
|
RandomAccessOutputStream(String file)
Constructs a random access stream around the given file.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
long |
getFilePointer()
Returns the current offset within the stream.
|
boolean |
isLittleEndian()
Gets the endianness of the stream.
|
long |
length()
Returns the length of the file.
|
void |
order(boolean little)
Sets the endianness of the stream.
|
void |
seek(long pos)
Seeks to the given offset within the stream.
|
void |
skipBytes(int skip)
Advances the current offset by the given number of bytes.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(ByteBuffer b)
Writes bytes to the stream from the given buffer.
|
void |
write(ByteBuffer b,
int off,
int len) |
void |
write(int b) |
void |
writeBits(int value,
int numBits)
Writes the given value using the given number of bits.
|
void |
writeBits(String bitString)
Writes the bits represented by a bit string to the buffer.
|
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeBytes(String s) |
void |
writeChar(int v) |
void |
writeChars(String s) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
void |
writeLine(String s)
Writes the given string followed by a newline character.
|
void |
writeLong(long v) |
void |
writeShort(int v) |
void |
writeUTF(String str) |
private IRandomAccess outputFile
private int currentBit
private int currentByte
private boolean dirtyByte
public RandomAccessOutputStream(String file) throws IOException
file
- Filename to open the stream for.IOException
- If there is a problem opening the file.public RandomAccessOutputStream(IRandomAccess handle)
handle
- Handle to open the stream for.public RandomAccessOutputStream(byte[] array) throws IOException
IOException
public void seek(long pos) throws IOException
IOException
public long getFilePointer() throws IOException
IOException
public long length() throws IOException
IOException
public void skipBytes(int skip) throws IOException
IOException
public void order(boolean little)
public boolean isLittleEndian()
public void writeLine(String s) throws IOException
IOException
public void writeBits(int value, int numBits) throws IOException
IOException
public void writeBits(String bitString) throws IOException
IllegalArgumentException
- If any characters other than
'0' and '1' appear in the string.IOException
public void write(byte[] b) throws IOException
write
in interface DataOutput
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in interface DataOutput
write
in class OutputStream
IOException
public void write(ByteBuffer b) throws IOException
b
- Source buffer to read data from.IOException
- If there is an error writing to the stream.public void write(ByteBuffer b, int off, int len) throws IOException
b
- Source buffer to read data from.off
- Offset within the buffer to start reading from.len
- Number of bytes to read.IOException
- If there is an error writing to the stream.public void write(int b) throws IOException
write
in interface DataOutput
write
in class OutputStream
IOException
public void writeBoolean(boolean v) throws IOException
writeBoolean
in interface DataOutput
IOException
public void writeByte(int v) throws IOException
writeByte
in interface DataOutput
IOException
public void writeBytes(String s) throws IOException
writeBytes
in interface DataOutput
IOException
public void writeChar(int v) throws IOException
writeChar
in interface DataOutput
IOException
public void writeChars(String s) throws IOException
writeChars
in interface DataOutput
IOException
public void writeDouble(double v) throws IOException
writeDouble
in interface DataOutput
IOException
public void writeFloat(float v) throws IOException
writeFloat
in interface DataOutput
IOException
public void writeInt(int v) throws IOException
writeInt
in interface DataOutput
IOException
public void writeLong(long v) throws IOException
writeLong
in interface DataOutput
IOException
public void writeShort(int v) throws IOException
writeShort
in interface DataOutput
IOException
public void writeUTF(String str) throws IOException
writeUTF
in interface DataOutput
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
Copyright © 2015 Open Microscopy Environment