Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ru.biosoft.util
Class FastFileBuffer

    java.lang.Object
      ru.biosoft.util.FileBuffer
          ru.biosoft.util.FastFileBuffer

public class FastFileBuffer
extends FileBuffer

Optimized by speed implementation of `FileBuffer` interface.

Field Summary
`protected static org.apache.log4j.Category` | `cat`

Constructor Summary
`FastFileBuffer(java.io.File file)` Constructs the RandomAccessBuffer object.
`FastFileBuffer(java.io.File file, int sz)` Constructs the RandomAccessBuffer object .
`FastFileBuffer(java.io.RandomAccessFile rndFile)` Constructs the RandomAccessBuffer object .
`FastFileBuffer(java.io.RandomAccessFile rndFile, int sz)` Constructs the RandomAccessBuffer object .

Method Summary
`void` | `close()` Closes the buffer.
`protected void` | `finalize()` Stores all buffers and closes random access file
`byte` | `read(int pos)` Reads one byte from requested position.
`void` | `write(int pos, byte bt)` Writes one byte to the requested position in the buffer.

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### cat

    protected static org.apache.log4j.Category cat

Constructor Detail

### FastFileBuffer

    public FastFileBuffer(java.io.RandomAccessFile rndFile,
                          int sz)
                   throws java.io.IOException

  Constructs the RandomAccessBuffer object .
  Creates two buffers by size sz
  fills them with preceding reading

Parameters:
  `rndFile` - random access file
  `sz` - Size of one buffer.
Throws:
  `java.io.IOException` - any I/O errors

### FastFileBuffer

    public FastFileBuffer(java.io.RandomAccessFile rndFile)
                   throws java.io.IOException

  Constructs the RandomAccessBuffer object .
  Creates two buffers by size `sz`
  fills them with preceding reading

Parameters:
  `rndFile` - random access file
Throws:
  `java.io.IOException` - any I/O errors

### FastFileBuffer

    public FastFileBuffer(java.io.File file,
                          int sz)
                   throws java.io.IOException

  Constructs the RandomAccessBuffer object .
  Creates two buffers by size sz
  fills them with preceding reading

Parameters:
  `file` - random access file
  `sz` - Size of one buffer.
Throws:
  `java.io.IOException` - any I/O errors

### FastFileBuffer

    public FastFileBuffer(java.io.File file)
                   throws java.io.IOException

  Constructs the RandomAccessBuffer object.
  Creates two buffers by size sz
  fills them with preceding reading

Parameters:
  `file` - random access file
Throws:
  `java.io.IOException` - any I/O errors

Method Detail

### read

    public byte read(int pos)
              throws java.io.IOException

  Reads one byte from requested position. If byte is already in any buffer then it returns. Otherwise one of two buffers is filled by new data from position pos minus half buffer size. Method selects buffer which more distant from specified position.

  Specified by:
    `read` in class `FileBuffer`
  Parameters:
    `pos` - position of requested byte
  Returns:
    requested byte
  Throws:
    `java.io.IOException` - any I/O errors

### write

    public void write(int pos,
                      byte bt)
               throws java.io.IOException

  Writes one byte to the requested position in the buffer. If specified position maps to any region in any of the two buffers the byte is stored into the buffer. Otherwise one of the two buffers is written into file and required portion of data is read from file back into buffer so it will satisfy the requested position. Method selects buffer which more distant from specified position.

  Specified by:
    `write` in class `FileBuffer`
  Parameters:
    `pos` - position of requested byte
    `bt` - stored byte
  Throws:
    `java.io.IOException` - any I/O errors

### close

    public void close()
               throws java.io.IOException

  Closes the buffer.

  Specified by:
    `close` in class `FileBuffer`
  Throws:
    `java.io.IOException` - if an I/O error occurs.

### finalize

    protected void finalize()
                     throws java.lang.Throwable

  Stores all buffers and closes random access file

  Throws:
    `java.lang.Throwable` - any errors

Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2003 Biosof.Ru. All Rights Reserved.