de.schlichtherle.io.rof
Class ChannelReadOnlyFile

java.lang.Object
  extended by de.schlichtherle.io.rof.AbstractReadOnlyFile
      extended by de.schlichtherle.io.rof.ChannelReadOnlyFile
All Implemented Interfaces:
ReadOnlyFile

public class ChannelReadOnlyFile
extends AbstractReadOnlyFile

A ReadOnlyFile implementation using file channels.

Version:
TrueZIP 6.7
Author:
Christian Schlichtherle

Constructor Summary
ChannelReadOnlyFile(File file)
           
 
Method Summary
 void close()
           
 long getFilePointer()
           
 long length()
           
 int read()
           
 int read(byte[] buf, int off, int len)
          Reads up to len bytes of data from this read only file into the given array.
 void seek(long fp)
          Sets the file pointer offset, measured from the beginning of this file, at which the next read occurs.
 
Methods inherited from class de.schlichtherle.io.rof.AbstractReadOnlyFile
read, readFully, readFully, skipBytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelReadOnlyFile

public ChannelReadOnlyFile(File file)
                    throws FileNotFoundException
Throws:
FileNotFoundException
Method Detail

length

public long length()
            throws IOException
Throws:
IOException

getFilePointer

public long getFilePointer()
                    throws IOException
Throws:
IOException

seek

public void seek(long fp)
          throws IOException
Description copied from interface: ReadOnlyFile
Sets the file pointer offset, measured from the beginning of this file, at which the next read occurs. Whether the offset may be set beyond the end of the file is up to the implementor. For example, the SimpleReadOnlyFile subclasses RandomAccessFile and passes "r" as a parameter to the superclass constructor. On the Windows platform, this implementation allows to seek past the end of file, but on the Linux platform it doesn't.

Parameters:
fp - The offset position, measured in bytes from the beginning of the file, at which to set the file pointer.
Throws:
IOException - If pos is less than 0 or if an I/O error occurs.

read

public int read()
         throws IOException
Throws:
IOException

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Description copied from interface: ReadOnlyFile
Reads up to len bytes of data from this read only file into the given array. This method blocks until at least one byte of input is available.

Parameters:
buf - The buffer to fill with data.
off - The start offset of the data.
len - The maximum number of bytes to read.
Returns:
The total number of bytes read, or -1 if there is no more data because the end of the file has been reached.
Throws:
IOException - On any I/O related issue.

close

public void close()
           throws IOException
Throws:
IOException