com.izforge.izpack.io
Class FileSpanningInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.izforge.izpack.io.FileSpanningInputStream
All Implemented Interfaces:
java.io.Closeable

public class FileSpanningInputStream
extends java.io.InputStream

An inputstream which transparently spans over multiple volumes. The amount of volumes has to be specified

Author:
Dennis Reil,

Field Summary
protected  int currentvolumeindex
           
private static int EOF
           
protected  java.io.FileInputStream fileinputstream
           
protected  long filepointer
           
protected  byte[] magicnumber
           
protected static boolean nextvolumenotfound
           
protected  java.lang.String volumename
           
protected  int volumestotal
           
protected  java.util.zip.GZIPInputStream zippedinputstream
           
 
Constructor Summary
FileSpanningInputStream(java.io.File volume, int volumestotal)
           
FileSpanningInputStream(java.lang.String volumename, int volumestotal)
           
 
Method Summary
 int available()
           
 void close()
           
private  boolean createInputStreamToNextVolume()
          creates an inputstream to the next volume
 long getFilepointer()
          Returns the current position in the file.
 java.lang.String getVolumename()
          Returns the name of the volume
private  boolean isMagicNumberValid()
          checks if the MagicNumber of this stream is valid.
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void setVolumename(java.lang.String volumename)
          Sets the volumename
 long skip(long n)
           
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOF

private static final int EOF
See Also:
Constant Field Values

fileinputstream

protected java.io.FileInputStream fileinputstream

volumename

protected java.lang.String volumename

currentvolumeindex

protected int currentvolumeindex

volumestotal

protected int volumestotal

nextvolumenotfound

protected static boolean nextvolumenotfound

filepointer

protected long filepointer

zippedinputstream

protected java.util.zip.GZIPInputStream zippedinputstream

magicnumber

protected byte[] magicnumber
Constructor Detail

FileSpanningInputStream

public FileSpanningInputStream(java.io.File volume,
                               int volumestotal)
                        throws java.io.IOException
Throws:
java.io.IOException

FileSpanningInputStream

public FileSpanningInputStream(java.lang.String volumename,
                               int volumestotal)
                        throws java.io.IOException
Throws:
java.io.IOException
Method Detail

isMagicNumberValid

private boolean isMagicNumberValid()
                            throws java.io.IOException
checks if the MagicNumber of this stream is valid. The stream has to be opened right before.

Returns:
wether the magic number is valid or not
Throws:
java.io.IOException

createInputStreamToNextVolume

private boolean createInputStreamToNextVolume()
                                       throws java.io.IOException
creates an inputstream to the next volume

Returns:
true - an inputstream to the next volume has been created false - the last volume was reached
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

getVolumename

public java.lang.String getVolumename()
Returns the name of the volume

Returns:
the name of the volume

setVolumename

public void setVolumename(java.lang.String volumename)
Sets the volumename

Parameters:
volumename -

getFilepointer

public long getFilepointer()
Returns the current position in the file. Notice: this is the global position in all volumes.

Returns:
the current position in file.