Package i2p.susi.util

Class FileBuffer

java.lang.Object
i2p.susi.util.FileBuffer
All Implemented Interfaces:
Buffer
Direct Known Subclasses:
GzipFileBuffer

public class FileBuffer extends Object implements Buffer
File implementation of Buffer.
Since:
0.9.34
  • Field Details

    • _file

      protected final File _file
    • _offset

      protected final int _offset
    • _sublen

      protected final int _sublen
  • Constructor Details

    • FileBuffer

      public FileBuffer(File file)
    • FileBuffer

      public FileBuffer(File file, int offset, int sublen)
  • Method Details

    • getFile

      public File getFile()
      Returns:
      the underlying file
    • getInputStream

      public InputStream getInputStream() throws IOException
      Caller must call readComplete()
      Specified by:
      getInputStream in interface Buffer
      Returns:
      new FileInputStream
      Throws:
      IOException
    • getOutputStream

      public OutputStream getOutputStream() throws IOException
      Caller must call writeComplete()
      Specified by:
      getOutputStream in interface Buffer
      Returns:
      new FileOutputStream
      Throws:
      IOException
    • readComplete

      public void readComplete(boolean success)
      Description copied from interface: Buffer
      Top-level reader MUST call this to close the input stream.
      Specified by:
      readComplete in interface Buffer
    • writeComplete

      public void writeComplete(boolean success)
      Deletes the file if success is false
      Specified by:
      writeComplete in interface Buffer
      Parameters:
      success - if false, deletes any resources
    • getLength

      public int getLength()
      Always valid if file exists
      Specified by:
      getLength in interface Buffer
    • getOffset

      public int getOffset()
      Always valid
      Specified by:
      getOffset in interface Buffer
    • toString

      public String toString()
      Overrides:
      toString in class Object