Class java.io.RandomAccessFile
All Packages    This Package    Previous    Next

Class java.io.RandomAccessFile

java.lang.Object
   |
   +----java.io.RandomAccessFile

public class RandomAccessFile
extends Object

RandomAccessFile(String, String)
Create a RandomAccessFile given a file name.
RandomAccessFile(int)
Create a RandomAccessFile given a file descriptor.
RandomAccessFile(File, String)
Create a RandomAccessFile given a File object and mode ("r" or "rw").

close()
Close the file.
getFilePointer()
Return the current location of the file pointer
length()
Return the length of the file.
read()
Read a byte
read(byte[])
Read an array of bytes
read(byte[], int, int)
readBoolean()
Read a boolean
readByte()
Read a byte
readChar()
Read char
readInt()
Read int
readLine()
Read a line terminated by a '\n' or EOF.
readLong()
Read long
readShort()
Read short
readUTF()
Read a UTF format string
seek(int)
Set the file pointer to the specified absolute position
write(int)
Write a byte.
write(byte[])
Write an array of bytes
write(byte[], int, int)
writeBoolean(boolean)
Write a boolean
writeByte(int)
Write a byte
writeBytes(String)
Write a string as a sequence of bytes REMIND: need to add support for more data types
writeChar(int)
Write char
writeChars(String)
Write a string as a sequence of chars
writeInt(int)
Write int
writeLong(long)
Write long
writeShort(int)
Write short
writeUTF(String)
Write string in UTF format

RandomAccessFile
  public RandomAccessFile(String name,
                          String mode)
Create a RandomAccessFile given a file name. Mode is "r" for read-only, "rw" for read+write. May throw IOException. The file name is very system dependent!

RandomAccessFile

  public RandomAccessFile(int fd)
Create a RandomAccessFile given a file descriptor. May throw IOException. The use of file descriptor is very system dependent!

RandomAccessFile

  public RandomAccessFile(File file,
                          String mode)
Create a RandomAccessFile given a File object and mode ("r" or "rw").

read
  public int read()
Read a byte

read

  public int read(byte b[])
Read an array of bytes

read

  public int read(byte b[],
                  int off,
                  int len)
write
  public void write(int b)
Write a byte.

write

  public void write(byte b[])
Write an array of bytes

write

  public void write(byte b[],
                    int off,
                    int len)
getFilePointer
  public int getFilePointer()
Return the current location of the file pointer

seek

  public void seek(int pos)
Set the file pointer to the specified absolute position

length

  public int length()
Return the length of the file.

close

  public void close()
Close the file. (We need destructors!)

readBoolean

  public final boolean readBoolean()
Read a boolean

readByte

  public final byte readByte()
Read a byte

readShort

  public final short readShort()
Read short

readChar

  public final char readChar()
Read char

readInt

  public final int readInt()
Read int

readLong

  public final long readLong()
Read long

readLine

  public final String readLine()
Read a line terminated by a '\n' or EOF.

readUTF

  public final String readUTF()
Read a UTF format string

writeBoolean

  public final void writeBoolean(boolean v)
Write a boolean

writeByte

  public final void writeByte(int v)
Write a byte

writeShort

  public final void writeShort(int v)
Write short

writeChar

  public final void writeChar(int v)
Write char

writeInt

  public final void writeInt(int v)
Write int

writeLong

  public final void writeLong(long v)
Write long

writeBytes

  public final void writeBytes(String s)
Write a string as a sequence of bytes REMIND: need to add support for more data types

writeChars

  public final void writeChars(String s)
Write a string as a sequence of chars

writeUTF

  public final void writeUTF(String str)
Write string in UTF format


All Packages    This Package    Previous    Next