All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Interface org.jos.fs.FSFile

public interface FSFile
Interface to a random access file

Any implementation of this interface must be thread-safe!

TODO: I don't like that read and write return ints. They should return nothing, but throw an IOException in case of an error. Unlike InputStream, a FSFile knows its size, so callers can check how much they can read before they read. They don't need the return value to see how much has been read.
Besides, action methods returning ints or pointers are C-style. In Java, these methods usually return void.

Version:
JOS-FileSystem 4 Preview (25-Mar-98)
Author:
Stefan Reich
See Also:
FileSystem, FSManager

Method Index

 o close()
 o flush()
 o getFilePointer()
 o getFileSize()
 o read(byte[], int, int)
Unlike InputStream.read methods, FSFile.read does not return "partial data".
 o setFilePointer(long)
 o truncate()
 o write(byte[], int, int)
Similar to read(), write() does not write partial data.

Methods

 o read
public abstract int read(byte[] b,
                         int off,
                         int len) throws IOException
Unlike InputStream.read methods, FSFile.read does not return "partial data". If the return value is less than len, it means that the end of file is reached. A subsequent read returns -1.

 o write
public abstract int write(byte[] b,
                          int off,
                          int len) throws IOException
Similar to read(), write() does not write partial data. It writes all or nothing.

 o close
public abstract void close() throws IOException
 o flush
public abstract void flush() throws IOException
 o getFilePointer
public abstract long getFilePointer() throws IOException
 o getFileSize
public abstract long getFileSize() throws IOException
 o setFilePointer
public abstract void setFilePointer(long pos) throws IOException
 o truncate
public abstract void truncate() throws IOException

All Packages  Class Hierarchy  This Package  Previous  Next  Index