org.apache.cassandra.io
Class BufferedRandomAccessFile

java.lang.Object
  extended by java.io.RandomAccessFile
      extended by org.apache.cassandra.io.BufferedRandomAccessFile
All Implemented Interfaces:
java.io.Closeable, java.io.DataInput, java.io.DataOutput

public final class BufferedRandomAccessFile
extends java.io.RandomAccessFile

A BufferedRandomAccessFile is like a RandomAccessFile, but it uses a private buffer so that most operations do not require a disk access.

Note: The operations on this class are unmonitored. Also, the correct functioning of the RandomAccessFile methods that are not overridden here relies on the implementation of those methods in the superclass.


Field Summary
static int BuffSz_
           
 
Constructor Summary
BufferedRandomAccessFile(java.io.File file, java.lang.String mode)
          Open a new BufferedRandomAccessFile on file in mode mode, which should be "r" for reading only, or "rw" for reading and writing.
BufferedRandomAccessFile(java.io.File file, java.lang.String mode, int size)
           
BufferedRandomAccessFile(java.lang.String name, java.lang.String mode)
          Open a new BufferedRandomAccessFile on the file named name in mode mode, which should be "r" for reading only, or "rw" for reading and writing.
BufferedRandomAccessFile(java.lang.String name, java.lang.String mode, int size)
           
 
Method Summary
 void close()
           
 void flush()
          Flush any bytes in the file's buffer that have not yet been written to disk.
 long getFilePointer()
           
 java.lang.String getPath()
           
 boolean isEOF()
           
 long length()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void seek(long pos)
           
 void sync()
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.RandomAccessFile
getChannel, getFD, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, setLength, skipBytes, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BuffSz_

public static final int BuffSz_
See Also:
Constant Field Values
Constructor Detail

BufferedRandomAccessFile

public BufferedRandomAccessFile(java.io.File file,
                                java.lang.String mode)
                         throws java.io.IOException
Open a new BufferedRandomAccessFile on file in mode mode, which should be "r" for reading only, or "rw" for reading and writing.

Throws:
java.io.IOException

BufferedRandomAccessFile

public BufferedRandomAccessFile(java.io.File file,
                                java.lang.String mode,
                                int size)
                         throws java.io.IOException
Throws:
java.io.IOException

BufferedRandomAccessFile

public BufferedRandomAccessFile(java.lang.String name,
                                java.lang.String mode)
                         throws java.io.IOException
Open a new BufferedRandomAccessFile on the file named name in mode mode, which should be "r" for reading only, or "rw" for reading and writing.

Throws:
java.io.IOException

BufferedRandomAccessFile

public BufferedRandomAccessFile(java.lang.String name,
                                java.lang.String mode,
                                int size)
                         throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException
Method Detail

getPath

public java.lang.String getPath()

sync

public void sync()
          throws java.io.IOException
Throws:
java.io.IOException

isEOF

public boolean isEOF()
              throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.RandomAccessFile
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Flush any bytes in the file's buffer that have not yet been written to disk. If the file was created read-only, this method is a no-op.

Throws:
java.io.IOException

seek

public void seek(long pos)
          throws java.io.IOException
Overrides:
seek in class java.io.RandomAccessFile
Throws:
java.io.IOException

getFilePointer

public long getFilePointer()
Overrides:
getFilePointer in class java.io.RandomAccessFile

length

public long length()
            throws java.io.IOException
Overrides:
length in class java.io.RandomAccessFile
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.RandomAccessFile
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.RandomAccessFile
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.RandomAccessFile
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in interface java.io.DataOutput
Overrides:
write in class java.io.RandomAccessFile
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Specified by:
write in interface java.io.DataOutput
Overrides:
write in class java.io.RandomAccessFile
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Specified by:
write in interface java.io.DataOutput
Overrides:
write in class java.io.RandomAccessFile
Throws:
java.io.IOException


Copyright © 2010 The Apache Software Foundation