TrueZIP Kernel 7.0-rc2

de.schlichtherle.truezip.rof
Interface ReadOnlyFile

All Superinterfaces:
Closeable
All Known Implementing Classes:
AbstractReadOnlyFile, BufferedReadOnlyFile, ByteArrayReadOnlyFile, ConcurrentInputShop.ConcurrentReadOnlyFile, ConcurrentInputShop.SynchronizedConcurrentReadOnlyFile, DecoratingReadOnlyFile, DefaultReadOnlyFile, FsStatistics.CountingReadOnlyFile, IOCache.Buffer.BufferReadOnlyFile, LazyInputSocket.ProxyReadOnlyFile, SynchronizedReadOnlyFile

public interface ReadOnlyFile
extends Closeable

Provides random read-only access to a file. The methods of this interface form a subset of RandomAccessFile which is required for random read-only access. The default implementation can be found in DefaultReadOnlyFile.

Though not strictly required, implementations should be thread-safe. At least they should document their level of thread-safety.

Author:
Christian Schlichtherle

Method Summary
 void close()
          Closes this read-only file and releases any non-heap resources allocated for it.
 long getFilePointer()
          Returns the current byte position in the file as a zero-based index.
 long length()
          Returns the length of the file in bytes.
 int read()
          Reads and returns the next byte or -1 if the end of the file has been reached.
 int read(byte[] b)
          Equivalent to read(b, 0, b.length).
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from this read only file into the given array.
 void readFully(byte[] b)
          Equivalent to readFully(b, 0, b.length).
 void readFully(byte[] b, int off, int len)
          Reads len bytes into the given buffer at the given position.
 void seek(long pos)
          Sets the current byte position in the file as a zero-based index at which the next read occurs.
 

Method Detail

length

long length()
            throws IOException
Returns the length of the file in bytes.

Throws:
IOException

getFilePointer

long getFilePointer()
                    throws IOException
Returns the current byte position in the file as a zero-based index.

Throws:
IOException

seek

void seek(long pos)
          throws IOException
Sets the current byte position in the file as a zero-based index 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 DefaultReadOnlyFile subclass RandomAccessFile passes "r" as a parameter to the superclass constructor. With Sun's JSE implementation, on the Windows platform this implementation allows to seek past the end of file, but on the Linux platform it doesn't.

Parameters:
pos - The current byte position as a zero-based index.
Throws:
IOException - If pos is less than 0 or if an I/O error occurs.

read

int read()
         throws IOException
Reads and returns the next byte or -1 if the end of the file has been reached.

Throws:
IOException

read

int read(byte[] b)
         throws IOException
Equivalent to read(b, 0, b.length).

Throws:
IOException

read

int read(byte[] b,
         int off,
         int len)
         throws IOException
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:
b - 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.

readFully

void readFully(byte[] b)
               throws IOException
Equivalent to readFully(b, 0, b.length).

Throws:
IOException

readFully

void readFully(byte[] b,
               int off,
               int len)
               throws IOException
Reads len bytes into the given buffer at the given position.

Parameters:
b - The buffer to fill with data.
off - The start offset of the data.
len - The number of bytes to read.
Throws:
EOFException - If less than len bytes are available before the end of the file is reached.
IOException - On any I/O related issue.

close

void close()
           throws IOException
Closes this read-only file and releases any non-heap resources allocated for it.

Specified by:
close in interface Closeable
Throws:
IOException

TrueZIP Kernel 7.0-rc2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.