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

## ru.biosoft.util
Class SoftFileBuffer

    ru.biosoft.util.FileBuffer
      |
      +--ru.biosoft.util.SoftFileBuffer

public class SoftFileBuffer
extends FileBuffer

Optimized by memory size implementation of FileBuffer interface. SoftFileBuffer provides buffered reading/writing of random access file Created buffers are based on SoftReference memory allocation.

Constructor Summary
`SoftFileBuffer(RandomAccessFile rndFile, int sz)` Constructs the RandomAccessBuffer object.
`SoftFileBuffer(RandomAccessFile rndFile)` Constructs the RandomAccessBuffer object using specified RandomAccessFile.
`SoftFileBuffer(File file, int sz)` Constructs the RandomAccessBuffer object using specified file and size of buffer.
`SoftFileBuffer(File file)` Constructs the RandomAccessBuffer object using specified file .

Method Summary
`void` | `close()` Closes the buffer.
`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.

Constructor Detail

### SoftFileBuffer

    public SoftFileBuffer(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:
    IOException - any I/O error

### SoftFileBuffer

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

  Constructs the RandomAccessBuffer object using specified RandomAccessFile.
  Parameters:
    rndFile - specified random access file.
  Throws:
    IOException - If any I/O error.

### SoftFileBuffer

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

  Constructs the RandomAccessBuffer object using specified file and size of buffer.
  Parameters:
    file - specified file.
    sz - size of each buffer
  Throws:
    IOException If - any I/O error.

### SoftFileBuffer

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

  Constructs the RandomAccessBuffer object using specified file .
  Parameters:
    file - specified file.
  Throws:
    IOException If - any I/O error.

Method Detail

### close

    public void close()
                throws java.io.IOException

  Closes the buffer.
  Throws:
    IOException - if an I/O error occurs.

### 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.
  Parameters:
    pos - position of requested byte
  Returns: requested byte
  Throws:
    IOException - If 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.
  Parameters:
    pos - position of requested byte
    bt - stored byte
  Throws:
    IOException - if any I/O errors

Association Links

to Class org.apache.log4j.Category

to Class java.io.RandomAccessFile

to Class java.lang.ref.SoftReference

to Class java.lang.ref.SoftReference

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

BOTTOM