opencard.opt.iso.fs
Class CardFileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by opencard.opt.iso.fs.CardFileInputStream
All Implemented Interfaces:
java.io.Closeable

public class CardFileInputStream
extends java.io.InputStream

CardFileInputStream together with the accompanying CardFileOutputStream provides access to a CardFile via the familiar Java input/output stream mechanism.

This class only works on transparent files.

Version:
$Id: CardFileInputStream.java,v 1.2 1999/11/03 12:37:17 damke Exp $
Author:
Peter Trommler (trp@zurich.ibm.com), Dirk Husemann (hud@zurich.ibm.com)
See Also:
CardFile, CardFileOutputStream, InputStream

Constructor Summary
CardFileInputStream(CardFile file)
          Instantiate an input stream using the specified CardFile object.
 
Method Summary
 int available()
          Return the number of byte available for reading.
 void close()
          Close the input stream and release any resources associated with the stream.
protected  void finalize()
          Close the stream at garbage collection time.
 int read()
          Read a byte of data.
 int read(byte[] b)
          Read data into a byte array.
 int read(byte[] b, int offset, int length)
          Reads data into a slice of a byte array.
 long skip(long n)
          Skips n bytes of input.
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CardFileInputStream

public CardFileInputStream(CardFile file)
                    throws java.io.IOException,
                           CardTerminalException,
                           CardIOException
Instantiate an input stream using the specified CardFile object.

Parameters:
file - The CardFile object to base the input stream on.
Throws:
java.io.IOException - Thrown when the file open fails.
CardIOException - The file is not found or it's type is not transparent.
CardTerminalException - Thrown when the smart card has been removed.
Method Detail

available

public int available()
              throws java.io.IOException,
                     CardTerminalException
Return the number of byte available for reading.

Overrides:
available in class java.io.InputStream
Returns:
The number of bytes available for reading without blocking.
Throws:
java.io.IOException - Thrown if we encounter an IO error.
CardTerminalException - Thrown when the smart card has been removed.

close

public void close()
           throws java.io.IOException,
                  CardTerminalException
Close the input stream and release any resources associated with the stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - Thrown if an I/O error has occurred.
CardTerminalException - Thrown when the smart card has been removed.

read

public int read()
         throws java.io.IOException,
                CardTerminalException
Read a byte of data.

Specified by:
read in class java.io.InputStream
Returns:
The byte read, or -1 if we reached the end of the input stream.
Throws:
java.io.IOException - Thrown if we encounter IO trouble.
CardTerminalException - Thrown when the smart card has been removed.

read

public int read(byte[] b)
         throws java.io.IOException,
                CardTerminalException
Read data into a byte array.

Overrides:
read in class java.io.InputStream
Parameters:
b - The buffer to use.
Returns:
The actual number of bytes read, or -1 if we reached the end of the input stream.
Throws:
java.io.IOException - Thrown if an IO error occured.
CardTerminalException - Thrown when the smart card has been removed.

read

public int read(byte[] b,
                int offset,
                int length)
         throws java.io.IOException,
                CardTerminalException
Reads data into a slice of a byte array.

Overrides:
read in class java.io.InputStream
Parameters:
b - The buffer into which the data is read
offset - The start offset of the data
length - The maximum number of bytes to be read
Returns:
The actual number of bytes read, or -1 if we reached end of the rainbow, err, input stream.
Throws:
java.io.IOException - Thrown if an I/O error has occured.
CardTerminalException - Thrown when the smart card has been removed.

skip

public long skip(long n)
          throws java.io.IOException,
                 CardTerminalException
Skips n bytes of input.

Overrides:
skip in class java.io.InputStream
Parameters:
n - The number of bytes to be skipped
Returns:
The actual number of bytes skipped.
Throws:
java.io.IOException - Thrown when skip()ing was not possible.
CardTerminalException - Thrown when the smart card has been removed.

finalize

protected void finalize()
                 throws java.io.IOException
Close the stream at garbage collection time.

Overrides:
finalize in class java.lang.Object
Throws:
java.io.IOException - Thrown when we encountered an IO error.