|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jouvieje.fmodex.utils.FileIOUtils
This class is an utility to read/write from a RandomAccessFile
.
Field Summary |
Fields inherited from interface org.jouvieje.fmodex.utils.SizeOfPrimitive |
SIZEOF_BYTE, SIZEOF_CHAR, SIZEOF_DOUBLE, SIZEOF_FLOAT, SIZEOF_INT, SIZEOF_LONG, SIZEOF_SHORT |
Constructor Summary | |
FileIOUtils()
|
Method Summary | |
void |
freeMemory()
Call this to free internal memory allocated |
byte |
readByte(java.io.RandomAccessFile file)
Read a simple byte into the file. |
void |
readByteArray(java.io.RandomAccessFile file,
byte[] datas,
int offset,
int nbBytes)
Read a byte[] from a file. |
byte[] |
readByteArray(java.io.RandomAccessFile file,
int nbBytes)
Read a byte[] from a file. |
void |
readByteBuffer(java.io.RandomAccessFile file,
java.nio.ByteBuffer buffer,
int nbBytes)
Read a ByteBuffer from a file. |
java.nio.ByteBuffer |
readByteBuffer(java.io.RandomAccessFile file,
int nbBytes)
Read a ByteBuffer from a file. |
char |
readChar(java.io.RandomAccessFile file)
Read a char from 2 bytes of the file. |
double |
readDouble(java.io.RandomAccessFile file)
Read a double from 8 bytes of the file. |
float |
readFloat(java.io.RandomAccessFile file)
Read a float from 4 bytes of the file. |
int |
readInt(java.io.RandomAccessFile file)
Read an int from 4 bytes of the file. |
long |
readLong(java.io.RandomAccessFile file)
Read a long from 8 bytes of the file. |
short |
readShort(java.io.RandomAccessFile file)
Read a short from 2 bytes of the file. |
void |
writeByte(java.io.RandomAccessFile file,
byte value)
Write a simple byte into the file. |
void |
writeByteArray(java.io.RandomAccessFile file,
byte[] datas)
Write an entire byte[] into the file. |
void |
writeByteArray(java.io.RandomAccessFile file,
byte[] datas,
int offset,
int length)
Write a part of a byte[] into the file. |
int |
writeByteBuffer(java.io.RandomAccessFile file,
java.nio.ByteBuffer buffer)
Write an entire ByteBuffer into a file. |
int |
writeByteBuffer(java.io.RandomAccessFile file,
java.nio.ByteBuffer buffer,
int length)
Write a part of a ByteBuffer into a file. |
void |
writeChar(java.io.RandomAccessFile file,
char value)
Convert the char in 2 bytes and write them into the file. |
void |
writeDouble(java.io.RandomAccessFile file,
double value)
Convert the double in 8 bytes and write them into the file. |
void |
writeFloat(java.io.RandomAccessFile file,
float value)
Convert the float in 4 bytes and write them into the file. |
void |
writeInt(java.io.RandomAccessFile file,
int value)
Convert the int in 4 bytes and write them into the file. |
void |
writeLong(java.io.RandomAccessFile file,
long value)
Convert the long in 8 bytes and write them into the file. |
void |
writeShort(java.io.RandomAccessFile file,
short value)
Convert the short |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FileIOUtils()
Method Detail |
public void freeMemory()
public byte readByte(java.io.RandomAccessFile file) throws java.io.IOException
byte
into the file.
byte
read from the file
java.io.IOException
- if an I/O error occures.public short readShort(java.io.RandomAccessFile file) throws java.io.IOException
short
from 2 bytes of the file.
short
read from the file.
java.io.IOException
- if an I/O error occures.public char readChar(java.io.RandomAccessFile file) throws java.io.IOException
char
from 2 bytes of the file.
char
read from the file.
java.io.IOException
- if an I/O error occures.public int readInt(java.io.RandomAccessFile file) throws java.io.IOException
int
from 4 bytes of the file.
int
read from the file.
java.io.IOException
- if an I/O error occures.public float readFloat(java.io.RandomAccessFile file) throws java.io.IOException
float
from 4 bytes of the file.
float
read from the file.
java.io.IOException
- if an I/O error occures.public long readLong(java.io.RandomAccessFile file) throws java.io.IOException
long
from 8 bytes of the file.
long
read from the file.
java.io.IOException
- if an I/O error occures.public double readDouble(java.io.RandomAccessFile file) throws java.io.IOException
double
from 8 bytes of the file.
double
read from the file.
java.io.IOException
- if an I/O error occures.public byte[] readByteArray(java.io.RandomAccessFile file, int nbBytes) throws java.io.IOException
byte[]
from a file.
nbBytes
- number of bytes to read.
byte[]
read from the file.
java.io.IOException
- if an I/O error occures.public void readByteArray(java.io.RandomAccessFile file, byte[] datas, int offset, int nbBytes) throws java.io.IOException
byte[]
from a file.
datas
- byte[]
into which the data is read.offset
- offsetnbBytes
- number of bytes to be read.
java.io.IOException
- if an I/O error occures.public java.nio.ByteBuffer readByteBuffer(java.io.RandomAccessFile file, int nbBytes) throws java.io.IOException
ByteBuffer
from a file.
nbBytes
- number of bytes to be read.
ByteBuffer
read from the file
java.io.IOException
- if an I/O error occures.public void readByteBuffer(java.io.RandomAccessFile file, java.nio.ByteBuffer buffer, int nbBytes) throws java.io.IOException
ByteBuffer
from a file.
buffer
- ByteBuffer
into which the data is read.nbBytes
- number of bytes to be read.
java.io.IOException
- if an I/O error occures.public void writeByte(java.io.RandomAccessFile file, byte value) throws java.io.IOException
byte
into the file.
file
- a file to read in.value
- a byte
to be written into the file.
java.io.IOException
- if an I/O exception occures.public void writeShort(java.io.RandomAccessFile file, short value) throws java.io.IOException
short in 2 bytes and write them into the file.
- Parameters:
file
- a file to read in.value
- a short to be written into the file.
- Throws:
java.io.IOException
- if an I/O exception occures.
public void writeChar(java.io.RandomAccessFile file, char value) throws java.io.IOException
char
in 2 bytes and write them into the file.
file
- a file to read in.value
- a char
to be writte into the file.
java.io.IOException
- if an I/O exception occures.public void writeInt(java.io.RandomAccessFile file, int value) throws java.io.IOException
int
in 4 bytes and write them into the file.
file
- a file to read in.value
- an int
to be written into the file.
java.io.IOException
- if an I/O exception occures.public void writeFloat(java.io.RandomAccessFile file, float value) throws java.io.IOException
float
in 4 bytes and write them into the file.
file
- a file to read in.value
- a float
to be written into the file.
java.io.IOException
- if an I/O exception occures.public void writeLong(java.io.RandomAccessFile file, long value) throws java.io.IOException
long
in 8 bytes and write them into the file.
file
- a file to read in.value
- a long
to be written into the file.
java.io.IOException
- if an I/O exception occures.public void writeDouble(java.io.RandomAccessFile file, double value) throws java.io.IOException
double
in 8 bytes and write them into the file.
file
- a file to read in.value
- a double
to be written into the file.
java.io.IOException
- if an I/O exception occures.public void writeByteArray(java.io.RandomAccessFile file, byte[] datas) throws java.io.IOException
byte[]
into the file.writeByteArray(file, datase, 0, datas.length)
file
- a file to read in.datas
- a byte[]
to be written into the file.
java.io.IOException
- if an I/O exception occures.public void writeByteArray(java.io.RandomAccessFile file, byte[] datas, int offset, int length) throws java.io.IOException
byte[]
into the file.
file
- a file to read in.datas
- a byte[]
to write into the file.offset
- offset from the start of the byte[]
.length
- number of bytes to be written starting from the offset of the byte[]
.
java.io.IOException
- if an I/O exception occures.public int writeByteBuffer(java.io.RandomAccessFile file, java.nio.ByteBuffer buffer) throws java.io.IOException
ByteBuffer
into a file.
file
- a file to read in.buffer
- a ByteBuffer
to be written into the file.
java.io.IOException
- if an I/O exception occures.public int writeByteBuffer(java.io.RandomAccessFile file, java.nio.ByteBuffer buffer, int length) throws java.io.IOException
ByteBuffer
into a file.
file
- a file to read in.buffer
- a ByteBuffer
to be written into the file.length
- number of bytes to be written into the file.
java.io.IOException
- if an I/O exception occures.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |