All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.IFSFileInputStream

java.lang.Object
   |
   +----java.io.InputStream
           |
           +----com.ibm.as400.access.IFSFileInputStream

public class IFSFileInputStream
extends InputStream
implements Serializable
The IFSFileInputStream class represents an integrated file system input stream. An integrated file system file input stream is an input stream for reading data from integrated file system objects.
IFSFileInputStream objects are capable of generating file events that call the following FileListener methods: fileClosed and fileOpened.
The following example illustrates the use of IFSFileInputStream:
// Work with /Dir/File on the system eniac.
AS400 as400 = new AS400("eniac");
IFSFileInputStream file = new IFSFileInputStream(as400, "/Dir/File");
// Determine how many bytes are available on the stream. int available = file.available();
// Lock the first 8 bytes of the file. IFSKey key = file.lock(8);
// Read the first 8 bytes. byte[] data = new byte[8]; int bytesRead = file.read(data, 0, 8);
// Unlock the first 8 bytes of the file. file.unlock(key);
// Close the file. file.close();

See Also:
FileEvent;, addFileListener, removeFileListener

Variable Index

 o fd_
 o SHARE_ALL
Share option that allows read and write access by other users.
 o SHARE_NONE
Share option that does not allow read or write access by other users.
 o SHARE_READERS
Share option that allows only read access by other users.
 o SHARE_WRITERS
Share option that allows only write access by other users.

Constructor Index

 o IFSFileInputStream()
Constructs an IFSFileInputStream.
 o IFSFileInputStream(AS400, IFSFile, int)
Creates a file input stream to read from the file specified by file.
 o IFSFileInputStream(AS400, String)
Constructs an IFSFileInputStream.
 o IFSFileInputStream(AS400, String, int)
Constructs an IFSFileInputStream.
 o IFSFileInputStream(IFSFileDescriptor)
Creates a file input stream to read from file descriptor fd.

Method Index

 o addFileListener(FileListener)
Adds a file listener to receive file events from this IFSFileInputStream.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a property change listener.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a vetoable change listener.
 o available()
Returns the number of bytes that can be read from this file input stream.
 o close()
Closes this file input stream and releases any system resources associated with the stream.
 o connectionDropped(ConnectionDroppedException)
Disconnects from the byte stream server.
 o finalize()
Ensures that the file input stream is closed when there are no more references to it.
 o getFD()
Returns the opaque file descriptor associated with this stream.
 o getPath()
Returns the integrated file system path name of the object represented by this IFSFileInputStream object.
 o getShareOption()
Returns the share option for this object.
 o getSystem()
Returns the AS400 system object for this file input stream.
 o lock(int)
Places a lock on the file at the current position for the specified number of bytes.
 o open()
Opens the specified file.
 o read()
Reads the next byte of data from this input stream.
 o read(byte[])
Reads up to data.length bytes of data from this input stream into data.
 o read(byte[], int, int)
Reads up to length bytes of data from this input stream into data, starting at the array offset dataOffset.
 o removeFileListener(FileListener)
Removes a file listener so that it no longer receives file events from this IFSFileInputStream.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a property change listener.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a vetoable change listener.
 o setFD(IFSFileDescriptor)
Sets the file descriptor.
 o setPath(String)
Sets the integrated file system path name.
 o setShareOption(int)
Sets the share option.
 o setSystem(AS400)
Sets the system.
 o skip(long)
Skips over the next bytesToSkip bytes in the file input stream.
 o unlock(IFSKey)
Undoes a lock on this file.

Variables

 o SHARE_ALL
 public static final int SHARE_ALL
Share option that allows read and write access by other users.

 o SHARE_NONE
 public static final int SHARE_NONE
Share option that does not allow read or write access by other users.

 o SHARE_READERS
 public static final int SHARE_READERS
Share option that allows only read access by other users.

 o SHARE_WRITERS
 public static final int SHARE_WRITERS
Share option that allows only write access by other users.

 o fd_
 protected IFSFileDescriptor fd_

Constructors

 o IFSFileInputStream
 public IFSFileInputStream()
Constructs an IFSFileInputStream. It creates a default file input stream.

 o IFSFileInputStream
 public IFSFileInputStream(AS400 system,
                           String name) throws AS400SecurityException, IOException
Constructs an IFSFileInputStream. It creates a file input stream to read from the file name. Other readers and writers are allowed to access the file. The file is opened if it exists; otherwise, an exception is thrown.

Parameters:
system - The AS400 that contains the file.
name - The integrated file system name.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: FileNotFoundException
If the file does not exist.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o IFSFileInputStream
 public IFSFileInputStream(AS400 system,
                           String name,
                           int shareOption) throws AS400SecurityException, IOException
Constructs an IFSFileInputStream. It creates a file input stream to read from the file name.

Parameters:
system - The AS/400 that contains the file.
name - The integrated file system name.
shareOption - Indicates how users can access the file.
  • SHARE_ALL Share access with readers and writers
  • SHARE_NONE Share access with none
  • SHARE_READERS Share access with readers
  • SHARE_WRITERS Share access with writers
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: FileNotFoundException
If the file does not exist.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o IFSFileInputStream
 public IFSFileInputStream(AS400 system,
                           IFSFile file,
                           int shareOption) throws AS400SecurityException, IOException
Creates a file input stream to read from the file specified by file.

Parameters:
system - The AS/400 that contains the file.
file - The file to be opened for reading.
shareOption - Indicates how users can access the file.
  • SHARE_ALL Share access with readers and writers
  • SHARE_NONE Share access with none
  • SHARE_READERS Share access with readers
  • SHARE_WRITERS Share access with writers
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: FileNotFoundException
If the file does not exist.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o IFSFileInputStream
 public IFSFileInputStream(IFSFileDescriptor fd)
Creates a file input stream to read from file descriptor fd.

Parameters:
fd - The file descriptor to be opened for reading.

Methods

 o addFileListener
 public synchronized void addFileListener(FileListener listener)
Adds a file listener to receive file events from this IFSFileInputStream.

Parameters:
listener - The file listener.
 o addPropertyChangeListener
 public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change listener.

Parameters:
listener - The property change listener to add.
 o addVetoableChangeListener
 public synchronized void addVetoableChangeListener(VetoableChangeListener listener)
Adds a vetoable change listener.

Parameters:
listener - The vetoable change listener to add.
 o available
 public int available() throws IOException
Returns the number of bytes that can be read from this file input stream.

Returns:
The number of bytes that can be read from this file input stream.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: FileNotFoundException
If the file does not exist.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Overrides:
available in class InputStream
 o close
 public void close() throws IOException
Closes this file input stream and releases any system resources associated with the stream.

Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: InterruptedIOException
If this thread is interrupted.
Overrides:
close in class InputStream
 o connectionDropped
 protected void connectionDropped(ConnectionDroppedException e) throws ConnectionDroppedException
Disconnects from the byte stream server.

Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
 o finalize
 protected void finalize() throws IOException
Ensures that the file input stream is closed when there are no more references to it.

Throws: IOException
If an error occurs while communicating with the AS/400.
Overrides:
finalize in class Object
 o getFD
 public final IFSFileDescriptor getFD() throws IOException
Returns the opaque file descriptor associated with this stream.

Returns:
The file descriptor object associated whith this stream.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
 o getPath
 public String getPath()
Returns the integrated file system path name of the object represented by this IFSFileInputStream object.

Returns:
The absolute path name of the object.
 o getShareOption
 public int getShareOption()
Returns the share option for this object.

Returns:
The share option.
 o getSystem
 public AS400 getSystem()
Returns the AS400 system object for this file input stream.

Returns:
The AS400 system object.
 o lock
 public IFSKey lock(int length) throws IOException
Places a lock on the file at the current position for the specified number of bytes.

Parameters:
length - The number of bytes to lock.
Returns:
The key for undoing this lock.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
See Also:
IFSKey, unlock
 o open
 protected void open() throws IOException
Opens the specified file.

 o read
 public int read() throws IOException
Reads the next byte of data from this input stream.

Returns:
The next byte of data, or -1 if the end of file is reached.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Overrides:
read in class InputStream
 o read
 public int read(byte data[]) throws IOException
Reads up to data.length bytes of data from this input stream into data.

Parameters:
data - The buffer into which data is read.
Returns:
The total number of bytes read into the buffer, or -1 if there is no more data because the end of file has been reached.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Overrides:
read in class InputStream
 o read
 public int read(byte data[],
                 int dataOffset,
                 int length) throws IOException
Reads up to length bytes of data from this input stream into data, starting at the array offset dataOffset.

Parameters:
data - The buffer into which the data is read.
offset - The start offset of the data in the buffer.
length - The maximum number of bytes to read
Returns:
The total number of bytes read into the buffer, or -1 if there is no more data because the end of file has been reached.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Overrides:
read in class InputStream
 o removeFileListener
 public synchronized void removeFileListener(FileListener listener)
Removes a file listener so that it no longer receives file events from this IFSFileInputStream.

Parameters:
listener - The file listener .
 o removePropertyChangeListener
 public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener.

Parameters:
listener - The property change listener to remove.
 o removeVetoableChangeListener
 public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a vetoable change listener.

Parameters:
listener - The vetoable change listener to remove.
 o setFD
 public void setFD(IFSFileDescriptor fd) throws PropertyVetoException
Sets the file descriptor.

Parameters:
fd - The file descriptor.
Throws: PropertyVetoException
If the change is vetoed.
 o setPath
 public void setPath(String path) throws PropertyVetoException
Sets the integrated file system path name.

Parameters:
path - The absolute integrated file system path name.
Throws: PropertyVetoException
If the change is vetoed.
 o setShareOption
 public void setShareOption(int shareOption) throws PropertyVetoException
Sets the share option.

Parameters:
shareOption - Indicates how users can access the file.
  • SHARE_ALL Share access with readers and writers
  • SHARE_NONE Share access with none
  • SHARE_READERS Share access with readers
  • SHARE_WRITERS Share access with writers
Throws: PropertyVetoException
If the change is vetoed.
 o setSystem
 public void setSystem(AS400 system) throws PropertyVetoException
Sets the system.

Parameters:
system - The AS/400 system object.
Throws: PropertyVetoException
If the change is vetoed.
 o skip
 public long skip(long bytesToSkip) throws IOException
Skips over the next bytesToSkip bytes in the file input stream. This method may skip less bytes than specified if the end of file is reached. The actual number of bytes skipped is returned.

Parameters:
bytesToSkip - The number of bytes to skip.
Returns:
The actual number of bytes skipped.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Overrides:
skip in class InputStream
 o unlock
 public void unlock(IFSKey key) throws IOException
Undoes a lock on this file.

Parameters:
key - The key for the lock.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
See Also:
IFSKey, lock

All Packages  Class Hierarchy  This Package  Previous  Next  Index