org.jouvieje.bass.misc
Class FileWriterUtils

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

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

This class allow you to write some datas into 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
FileWriterUtils()
           
 
Method Summary
static void writeByte(java.io.RandomAccessFile file, byte value)
          Write a simple byte into the file.
static void writeByteArray(java.io.RandomAccessFile file, byte[] datas)
          Write an entire byte[] into the file.
static void writeByteArray(java.io.RandomAccessFile file, byte[] datas, int offset, int length)
          Write a part of a byte[] into the file.
static int writeByteBuffer(java.io.RandomAccessFile file, java.nio.ByteBuffer buffer)
          Write an entire ByteBuffer into a file.
static int writeByteBuffer(java.io.RandomAccessFile file, java.nio.ByteBuffer buffer, int length)
          Write a part of a ByteBuffer into a file.
static void writeChar(java.io.RandomAccessFile file, char value)
          Convert the char in 2 bytes and write them into the file.
static void writeDouble(java.io.RandomAccessFile file, double value)
          Convert the double in 8 bytes and write them into the file.
static void writeFloat(java.io.RandomAccessFile file, float value)
          Convert the float in 4 bytes and write them into the file.
static void writeInt(java.io.RandomAccessFile file, int value)
          Convert the int in 4 bytes and write them into the file.
static void writeLong(java.io.RandomAccessFile file, long value)
          Convert the long in 8 bytes and write them into the file.
static void writeShort(java.io.RandomAccessFile file, short value)
          Convert the short in 2 bytes and write them into 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

FileWriterUtils

public FileWriterUtils()
Method Detail

writeByte

public static void writeByte(java.io.RandomAccessFile file,
                             byte value)
                      throws java.io.IOException
Write a simple byte into the file.

Parameters:
file - a file to read in.
value - a byte to be written into the file.
Throws:
java.io.IOException - if an I/O exception occures.

writeShort

public static void writeShort(java.io.RandomAccessFile file,
                              short value)
                       throws java.io.IOException
Convert the 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.

writeChar

public static void writeChar(java.io.RandomAccessFile file,
                             char value)
                      throws java.io.IOException
Convert the char in 2 bytes and write them into the file.

Parameters:
file - a file to read in.
value - a char to be writte into the file.
Throws:
java.io.IOException - if an I/O exception occures.

writeInt

public static void writeInt(java.io.RandomAccessFile file,
                            int value)
                     throws java.io.IOException
Convert the int in 4 bytes and write them into the file.

Parameters:
file - a file to read in.
value - an int to be written into the file.
Throws:
java.io.IOException - if an I/O exception occures.

writeFloat

public static void writeFloat(java.io.RandomAccessFile file,
                              float value)
                       throws java.io.IOException
Convert the float in 4 bytes and write them into the file.

Parameters:
file - a file to read in.
value - a float to be written into the file.
Throws:
java.io.IOException - if an I/O exception occures.

writeLong

public static void writeLong(java.io.RandomAccessFile file,
                             long value)
                      throws java.io.IOException
Convert the long in 8 bytes and write them into the file.

Parameters:
file - a file to read in.
value - a long to be written into the file.
Throws:
java.io.IOException - if an I/O exception occures.

writeDouble

public static void writeDouble(java.io.RandomAccessFile file,
                               double value)
                        throws java.io.IOException
Convert the double in 8 bytes and write them into the file.

Parameters:
file - a file to read in.
value - a double to be written into the file.
Throws:
java.io.IOException - if an I/O exception occures.

writeByteArray

public static void writeByteArray(java.io.RandomAccessFile file,
                                  byte[] datas)
                           throws java.io.IOException
Write an entire byte[] into the file.
This is equivalent to the call writeByteArray(file, datase, 0, datas.length)

Parameters:
file - a file to read in.
datas - a byte[] to be written into the file.
Throws:
java.io.IOException - if an I/O exception occures.

writeByteArray

public static void writeByteArray(java.io.RandomAccessFile file,
                                  byte[] datas,
                                  int offset,
                                  int length)
                           throws java.io.IOException
Write a part of a byte[] into the file.

Parameters:
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[].
Throws:
java.io.IOException - if an I/O exception occures.

writeByteBuffer

public static int writeByteBuffer(java.io.RandomAccessFile file,
                                  java.nio.ByteBuffer buffer)
                           throws java.io.IOException
Write an entire ByteBuffer into a file.

Parameters:
file - a file to read in.
buffer - a ByteBuffer to be written into the file.
Throws:
java.io.IOException - if an I/O exception occures.

writeByteBuffer

public static int writeByteBuffer(java.io.RandomAccessFile file,
                                  java.nio.ByteBuffer buffer,
                                  int length)
                           throws java.io.IOException
Write a part of a ByteBuffer into a file.

Parameters:
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.
Throws:
java.io.IOException - if an I/O exception 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)