|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.simantics.databoard.util.binary.BinaryFile
public class BinaryFile
This class is a Random Access File implementation to RandomAccessBinary. The implementation is buffered. The implementation is not multi-thread safe.
There is a buffer used for reading and writing. It has a buffer read and write position. When read, the buffer is filled. When written, the buffer is written. When the file pointer is moved, the file size changed or flushed the buffers are cleared. If there were unwritten bytes, they are flushed to disc.
There is internal pointer variable. The actual file pointer is moved on disc read and write operations.
Constructor Summary | |
---|---|
BinaryFile(java.io.File file)
|
|
BinaryFile(java.io.File file,
int bufSize)
|
|
BinaryFile(java.io.RandomAccessFile file)
|
|
BinaryFile(java.io.RandomAccessFile file,
int bufSize)
|
Method Summary | |
---|---|
void |
clearBuffer()
Clears read&write buffer. |
void |
close()
Closes the object. |
java.io.File |
file()
|
void |
flush()
Flushes internal buffer |
byte |
get()
|
void |
get(byte[] dst)
|
void |
get(byte[] dst,
int offset,
int length)
|
void |
get(java.nio.ByteBuffer buf)
Get buf fully |
void |
get(java.nio.ByteBuffer buf,
int length)
Get fully length bytes |
double |
getDouble()
|
float |
getFloat()
|
int |
getInt()
|
long |
getLong()
|
java.io.RandomAccessFile |
getRandomAccessFile()
|
short |
getShort()
|
void |
insertBytes(long bytes)
Insert bytes at current pointer. |
static void |
insertBytes(java.io.RandomAccessFile file,
long position,
long bytes)
Inserts bytes into a middle of a file. |
boolean |
isOpen()
|
long |
length()
Get the length of the binary object. |
java.nio.ByteOrder |
order()
Get byte order |
void |
order(java.nio.ByteOrder order)
Set a new byte order |
long |
position()
Get the position of the cursor |
void |
position(long newPosition)
Set new cursor position. |
void |
put(byte b)
Write a byte |
void |
put(byte[] src)
|
void |
put(byte[] src,
int offset,
int length)
|
void |
put(java.nio.ByteBuffer src)
Put n bytes from the remaining of the byte array. |
void |
put(java.nio.ByteBuffer src,
int length)
Put n bytes from the remaining of the byte buffer. |
void |
putDouble(double value)
|
void |
putFloat(float value)
|
void |
putInt(int value)
|
void |
putLong(long value)
|
void |
putShort(short value)
|
void |
removeBytes(long bytes)
Remove bytes from the position of the current pointer. |
static void |
removeBytes(java.io.RandomAccessFile file,
long position,
long bytes)
Remove bytes from a file |
void |
setLength(long newLength)
Set length of the binary object. |
void |
skip(long bytes)
Move pointer forward |
static BinaryFile |
tempFile(long size)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BinaryFile(java.io.RandomAccessFile file) throws java.io.IOException
java.io.IOException
public BinaryFile(java.io.File file) throws java.io.IOException
java.io.IOException
public BinaryFile(java.io.RandomAccessFile file, int bufSize) throws java.io.IOException
java.io.IOException
public BinaryFile(java.io.File file, int bufSize) throws java.io.IOException
java.io.IOException
Method Detail |
---|
public static BinaryFile tempFile(long size) throws java.io.IOException
java.io.IOException
public boolean isOpen()
public void close() throws java.io.IOException
close
in interface RandomAccessBinary
java.io.IOException
public java.io.File file()
public java.io.RandomAccessFile getRandomAccessFile()
public java.nio.ByteOrder order()
RandomAccessBinary
order
in interface BinaryReadable
order
in interface BinaryWriteable
order
in interface RandomAccessBinary
public void order(java.nio.ByteOrder order)
RandomAccessBinary
order
in interface BinaryReadable
order
in interface BinaryWriteable
order
in interface RandomAccessBinary
order
- new byte orderpublic byte get() throws java.io.IOException
get
in interface BinaryReadable
get
in interface RandomAccessBinary
java.io.IOException
public void get(byte[] dst, int offset, int length) throws java.io.IOException
get
in interface BinaryReadable
get
in interface RandomAccessBinary
java.io.IOException
public void get(byte[] dst) throws java.io.IOException
get
in interface BinaryReadable
get
in interface RandomAccessBinary
java.io.IOException
public void get(java.nio.ByteBuffer buf) throws java.io.IOException
RandomAccessBinary
get
in interface BinaryReadable
get
in interface RandomAccessBinary
java.io.IOException
public void get(java.nio.ByteBuffer buf, int length) throws java.io.IOException
RandomAccessBinary
get
in interface BinaryReadable
get
in interface RandomAccessBinary
java.io.IOException
public double getDouble() throws java.io.IOException
getDouble
in interface BinaryReadable
getDouble
in interface RandomAccessBinary
java.io.IOException
public float getFloat() throws java.io.IOException
getFloat
in interface BinaryReadable
getFloat
in interface RandomAccessBinary
java.io.IOException
public int getInt() throws java.io.IOException
getInt
in interface BinaryReadable
getInt
in interface RandomAccessBinary
java.io.IOException
public long getLong() throws java.io.IOException
getLong
in interface BinaryReadable
getLong
in interface RandomAccessBinary
java.io.IOException
public short getShort() throws java.io.IOException
getShort
in interface BinaryReadable
getShort
in interface RandomAccessBinary
java.io.IOException
public long position()
RandomAccessBinary
position
in interface BinaryReadable
position
in interface RandomAccessBinary
public void position(long newPosition)
RandomAccessBinary
position
in interface RandomAccessBinary
public void flush() throws java.io.IOException
flush
in interface BinaryWriteable
flush
in interface RandomAccessBinary
java.io.IOException
public void clearBuffer() throws java.io.IOException
java.io.IOException
public void skip(long bytes) throws java.io.IOException
RandomAccessBinary
skip
in interface BinaryReadable
skip
in interface RandomAccessBinary
java.io.IOException
public void put(byte b) throws java.io.IOException
RandomAccessBinary
put
in interface BinaryWriteable
put
in interface RandomAccessBinary
java.io.IOException
public void put(java.nio.ByteBuffer src) throws java.io.IOException
RandomAccessBinary
put
in interface BinaryWriteable
put
in interface RandomAccessBinary
java.io.IOException
public void put(java.nio.ByteBuffer src, int length) throws java.io.IOException
RandomAccessBinary
put
in interface BinaryWriteable
put
in interface RandomAccessBinary
java.io.IOException
public void put(byte[] src, int offset, int length) throws java.io.IOException
put
in interface BinaryWriteable
put
in interface RandomAccessBinary
java.io.IOException
public void put(byte[] src) throws java.io.IOException
put
in interface BinaryWriteable
put
in interface RandomAccessBinary
java.io.IOException
public void putDouble(double value) throws java.io.IOException
putDouble
in interface BinaryWriteable
putDouble
in interface RandomAccessBinary
java.io.IOException
public void putFloat(float value) throws java.io.IOException
putFloat
in interface BinaryWriteable
putFloat
in interface RandomAccessBinary
java.io.IOException
public void putInt(int value) throws java.io.IOException
putInt
in interface BinaryWriteable
putInt
in interface RandomAccessBinary
java.io.IOException
public void putLong(long value) throws java.io.IOException
putLong
in interface BinaryWriteable
putLong
in interface RandomAccessBinary
java.io.IOException
public void putShort(short value) throws java.io.IOException
putShort
in interface BinaryWriteable
putShort
in interface RandomAccessBinary
java.io.IOException
public void insertBytes(long bytes) throws java.io.IOException
RandomAccessBinary
insertBytes
in interface RandomAccessBinary
java.io.IOException
public void removeBytes(long bytes) throws java.io.IOException
RandomAccessBinary
removeBytes
in interface RandomAccessBinary
java.io.IOException
public long length() throws java.io.IOException
RandomAccessBinary
length
in interface BinaryReadable
length
in interface RandomAccessBinary
java.io.IOException
public void setLength(long newLength) throws java.io.IOException
RandomAccessBinary
setLength
in interface RandomAccessBinary
java.io.IOException
public static void insertBytes(java.io.RandomAccessFile file, long position, long bytes) throws java.io.IOException
file
- fileposition
- bytes
-
java.io.IOException
public static void removeBytes(java.io.RandomAccessFile file, long position, long bytes) throws java.io.IOException
file
- position
- bytes
-
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |