de.schlichtherle.io
Class FileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by de.schlichtherle.io.FileInputStream
All Implemented Interfaces:
Closeable

public class FileInputStream
extends FilterInputStream

A drop-in replacement for FileInputStream which provides transparent read access to archive entries as if they were (virtual) files. All file system operations in this class are virtually atomic.

To prevent exceptions to be thrown subsequently, client applications should always close their streams using the following idiom:


 FileInputStream fis = new FileInputStream(file);
 try {
     // access fis here
 } finally {
     fis.close();
 }
 

Note that for various (mostly archive driver specific) reasons, the close() method may throw an IOException, too. Client applications need to deal with this appropriately, for example by enclosing the entire block with another try-catch-block

Client applications cannot read from an entry in an archive file if an automatic update is required but cannot get performed because other FileInputStream or FileOutputStream instances haven't been closed or garbage collected yet. A FileBusyException is thrown by the constructors of this class in this case.

Whether or not a client application can read from more than one entry in the same archive archive file concurrently is an implementation detail of the respective archive driver. As of version 6.5, all archive drivers provided by TrueZIP don't restrict this. However, custom archive drivers provided by third parties may do so.

If a client application tries to exceed the number of entry streams supported to operate on the same archive file concurrently, a FileBusyException is thrown by the constructors of this class.

If you would like to use this class in order to copy files, please consider using the *copy* methods in the File class instead. These methods provide ease of use, enhanced features, superior performance and require less space in the temp file folder.

Version:
TrueZIP 6.7
Author:
Christian Schlichtherle
See Also:
Using Archive Entry Streams, FileBusyException, File.cat(java.io.InputStream, java.io.OutputStream), File.umount(), File.update()

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
FileInputStream(File file)
          Behaves like the super class, but also supports archive entry files.
FileInputStream(FileDescriptor fd)
          Behaves like the super class.
FileInputStream(String name)
          Behaves like the super class, but also supports archive entry files.
 
Method Summary
 int read(byte[] b)
           
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileInputStream

public FileInputStream(String name)
                throws FileNotFoundException
Behaves like the super class, but also supports archive entry files.

Throws:
FileBusyException - If the path denotes an archive entry and the archive driver does not support to create an additional stream for the archive file.
FileNotFoundException - On any other I/O related issue.

FileInputStream

public FileInputStream(File file)
                throws FileNotFoundException
Behaves like the super class, but also supports archive entry files.

Throws:
FileBusyException - If the path denotes an archive entry and the archive driver does not support to create an additional stream for the archive file.
FileNotFoundException - On any other I/O related issue.

FileInputStream

public FileInputStream(FileDescriptor fd)
Behaves like the super class.

Throws:
FileBusyException - If the path denotes an archive entry and the archive driver does not support to create an additional stream for the archive file.
Since:
TrueZIP 6.4
Method Detail

read

public int read(byte[] b)
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException