org.jouvieje.bass.misc
Class FileReaderUtils

java.lang.Object
  extended byorg.jouvieje.bass.misc.FileReaderUtils
All Implemented Interfaces:
org.jouvieje.bass.misc.SizeOfPrimitive

public class FileReaderUtils
extends java.lang.Object
implements org.jouvieje.bass.misc.SizeOfPrimitive

This class allow you to read some datas from a RandomAccessFile object.


Field Summary
static int SIZEOF_BYTE
          Size of a byte in bytes !!!
static int SIZEOF_CHAR
          Size of a char in bytes
static int SIZEOF_DOUBLE
          Size of a double in bytes
static int SIZEOF_FLOAT
          Size of a float in bytes
static int SIZEOF_INT
          Size of an int in bytes
static int SIZEOF_LONG
          Size of a long in bytes
static int SIZEOF_SHORT
          Size of a short in bytes
 
Constructor Summary
FileReaderUtils()
           
 
Method Summary
static byte readByte(java.io.RandomAccessFile file)
          Read a simple byte into the file.
static void readByteArray(java.io.RandomAccessFile file, byte[] datas, int offset, int nbBytes)
          Read a byte[] from a file.
static byte[] readByteArray(java.io.RandomAccessFile file, int nbBytes)
          Read a byte[] from a file.
static void readByteBuffer(java.io.RandomAccessFile file, java.nio.ByteBuffer buffer, int nbBytes)
          Read a ByteBuffer from a file.
static java.nio.ByteBuffer readByteBuffer(java.io.RandomAccessFile file, int nbBytes)
          Read a ByteBuffer from a file.
static char readChar(java.io.RandomAccessFile file)
          Read a char from 2 bytes of the file.
static double readDouble(java.io.RandomAccessFile file)
          Read a double from 8 bytes of the file.
static float readFloat(java.io.RandomAccessFile file)
          Read a float from 4 bytes of the file.
static int readInt(java.io.RandomAccessFile file)
          Read an int from 4 bytes of the file.
static long readLong(java.io.RandomAccessFile file)
          Read a long from 8 bytes of the file.
static short readShort(java.io.RandomAccessFile file)
          Read a short from 2 bytes of the file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZEOF_BYTE

public static final int SIZEOF_BYTE
Size of a byte in bytes !!!

See Also:
Constant Field Values

SIZEOF_CHAR

public static final int SIZEOF_CHAR
Size of a char in bytes

See Also:
Constant Field Values

SIZEOF_SHORT

public static final int SIZEOF_SHORT
Size of a short in bytes

See Also:
Constant Field Values

SIZEOF_INT

public static final int SIZEOF_INT
Size of an int in bytes

See Also:
Constant Field Values

SIZEOF_LONG

public static final int SIZEOF_LONG
Size of a long in bytes

See Also:
Constant Field Values

SIZEOF_FLOAT

public static final int SIZEOF_FLOAT
Size of a float in bytes

See Also:
Constant Field Values

SIZEOF_DOUBLE

public static final int SIZEOF_DOUBLE
Size of a double in bytes

See Also:
Constant Field Values
Constructor Detail

FileReaderUtils

public FileReaderUtils()
Method Detail

readByte

public static byte readByte(java.io.RandomAccessFile file)
                     throws java.io.IOException
Read a simple byte into the file.

Returns:
the byte read from the file
Throws:
java.io.IOException - if an I/O error occures.

readShort

public static short readShort(java.io.RandomAccessFile file)
                       throws java.io.IOException
Read a short from 2 bytes of the file.

Returns:
the short read from the file.
Throws:
java.io.IOException - if an I/O error occures.

readChar

public static char readChar(java.io.RandomAccessFile file)
                     throws java.io.IOException
Read a char from 2 bytes of the file.

Returns:
the char read from the file.
Throws:
java.io.IOException - if an I/O error occures.

readInt

public static int readInt(java.io.RandomAccessFile file)
                   throws java.io.IOException
Read an int from 4 bytes of the file.

Returns:
the int read from the file.
Throws:
java.io.IOException - if an I/O error occures.

readFloat

public static float readFloat(java.io.RandomAccessFile file)
                       throws java.io.IOException
Read a float from 4 bytes of the file.

Returns:
the float read from the file.
Throws:
java.io.IOException - if an I/O error occures.

readLong

public static long readLong(java.io.RandomAccessFile file)
                     throws java.io.IOException
Read a long from 8 bytes of the file.

Returns:
the long read from the file.
Throws:
java.io.IOException - if an I/O error occures.

readDouble

public static double readDouble(java.io.RandomAccessFile file)
                         throws java.io.IOException
Read a double from 8 bytes of the file.

Returns:
the double read from the file.
Throws:
java.io.IOException - if an I/O error occures.

readByteArray

public static byte[] readByteArray(java.io.RandomAccessFile file,
                                   int nbBytes)
                            throws java.io.IOException
Read a byte[] from a file.

Parameters:
nbBytes - number of bytes to read.
Returns:
the byte[] read from the file.
Throws:
java.io.IOException - if an I/O error occures.

readByteArray

public static void readByteArray(java.io.RandomAccessFile file,
                                 byte[] datas,
                                 int offset,
                                 int nbBytes)
                          throws java.io.IOException
Read a byte[] from a file.

Parameters:
datas - byte[] into which the data is read.
offset - offset
nbBytes - number of bytes to be read.
Throws:
java.io.IOException - if an I/O error occures.

readByteBuffer

public static java.nio.ByteBuffer readByteBuffer(java.io.RandomAccessFile file,
                                                 int nbBytes)
                                          throws java.io.IOException
Read a ByteBuffer from a file.

Parameters:
nbBytes - number of bytes to be read.
Returns:
the ByteBuffer read from the file
Throws:
java.io.IOException - if an I/O error occures.

readByteBuffer

public static void readByteBuffer(java.io.RandomAccessFile file,
                                  java.nio.ByteBuffer buffer,
                                  int nbBytes)
                           throws java.io.IOException
Read a ByteBuffer from a file.

Parameters:
buffer - ByteBuffer into which the data is read.
nbBytes - number of bytes to be read.
Throws:
java.io.IOException - if an I/O error occures.


NativeBass is an Open Source Project under GNU LGPL License
NativeBass Project - © Copyright 2007-2008 - Jérôme Jouvie (Jouvieje)
http://jerome.jouvie.free.fr/ - jerome.jouvie@gmail.com

(Documentation Copyright © Ian Luck - BASS - http://www.un4seen.com)