public class RandomAccessOutputStream extends OutputStream implements DataOutput, Closeable
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() |
boolean |
isLittleEndian()
Gets the endianness of the stream.
|
long |
length() |
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) |
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
array
- the byte array to be written toIOException
- if the array cannot be wrapped
in a ByteArrayHandle
public void seek(long pos) throws IOException
pos
- the new offset within the streamIOException
- is the seek is not successfulpublic long getFilePointer() throws IOException
IOException
- if the offset cannot be retrievedpublic long length() throws IOException
IOException
- if the length cannot be retrievedpublic void skipBytes(int skip) throws IOException
skip
- the number of bytes to skipIOException
- if the offset cannot be changedpublic void order(boolean little)
little
- true if the byte order of the stream is little-endianpublic boolean isLittleEndian()
public void writeLine(String s) throws IOException
s
- the line of text to be written. A newline does not
need to be appended, as this method automatically writes
a newline character.IOException
- if writing is not possiblepublic void writeBits(int value, int numBits) throws IOException
value
- int value to be writtennumBits
- exact number of bits to be writtenIOException
- if writing fails for any reasonpublic void writeBits(String bitString) throws IOException
bitString
- a string of '0' and/or '1' characters representing
bits to be written. Each character in the string results
in a call to writeBits(int, int)
that writes 1 bit.IllegalArgumentException
- If any characters other than
'0' and '1' appear in the string.IOException
- if writing fails for any other reasonpublic 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 © 2005–2020 Open Microscopy Environment. All rights reserved.