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
-
fd_
-
-
SHARE_ALL
- Share option that allows read and write access by other users.
-
SHARE_NONE
- Share option that does not allow read or write access by other users.
-
SHARE_READERS
- Share option that allows only read access by other users.
-
SHARE_WRITERS
- Share option that allows only write access by other users.
-
IFSFileInputStream()
- Constructs an IFSFileInputStream.
-
IFSFileInputStream(AS400, IFSFile, int)
- Creates a file input stream to read from the file specified by file.
-
IFSFileInputStream(AS400, IFSJavaFile, int)
- Creates a file input stream to read from the file specified by file.
-
IFSFileInputStream(AS400, String)
- Constructs an IFSFileInputStream.
-
IFSFileInputStream(AS400, String, int)
- Constructs an IFSFileInputStream.
-
IFSFileInputStream(IFSFileDescriptor)
- Creates a file input stream to read from file descriptor fd.
-
addFileListener(FileListener)
- Adds a file listener to receive file events from this IFSFileInputStream.
-
addPropertyChangeListener(PropertyChangeListener)
- Adds a property change listener.
-
addVetoableChangeListener(VetoableChangeListener)
- Adds a vetoable change listener.
-
available()
- Returns the number of bytes that can be read from this file input stream.
-
close()
- Closes this file input stream and releases any system resources associated
with the stream.
-
finalize()
- Ensures that the file input stream is closed when there are no more
references to it.
-
getFD()
- Returns the opaque file descriptor associated with this stream.
-
getPath()
- Returns the integrated file system path name of the object represented by this IFSFileInputStream object.
-
getShareOption()
- Returns the share option for this object.
-
getSystem()
- Returns the AS400 system object for this file input stream.
-
lock(int)
- Places a lock on the file at the current position for the specified
number of bytes.
-
open()
- Opens the specified file.
-
read()
- Reads the next byte of data from this input stream.
-
read(byte[])
- Reads up to data.length bytes of data from this input stream into
data.
-
read(byte[], int, int)
- Reads up to length bytes of data from this input stream into data, starting at the array offset dataOffset.
-
removeFileListener(FileListener)
- Removes a file listener so that it no longer receives file events from
this IFSFileInputStream.
-
removePropertyChangeListener(PropertyChangeListener)
- Removes a property change listener.
-
removeVetoableChangeListener(VetoableChangeListener)
- Removes a vetoable change listener.
-
rewind()
- Rewinds the input stream.
-
setFD(IFSFileDescriptor)
- Sets the file descriptor.
-
setPath(String)
- Sets the integrated file system path name.
-
setShareOption(int)
- Sets the share option.
-
setSystem(AS400)
- Sets the system.
-
skip(long)
- Skips over the next bytesToSkip bytes in the file input stream.
-
unlock(IFSKey)
- Undoes a lock on this file.
SHARE_ALL
public static final int SHARE_ALL
- Share option that allows read and write access by other users.
SHARE_NONE
public static final int SHARE_NONE
- Share option that does not allow read or write access by other users.
SHARE_READERS
public static final int SHARE_READERS
- Share option that allows only read access by other users.
SHARE_WRITERS
public static final int SHARE_WRITERS
- Share option that allows only write access by other users.
fd_
protected IFSFileDescriptor fd_
IFSFileInputStream
public IFSFileInputStream()
- Constructs an IFSFileInputStream.
It creates a default file input stream.
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: IOException
- If an error occurs while communicating with the AS/400.
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: IOException
- If an error occurs while communicating with the AS/400.
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: IOException
- If an error occurs while communicating with the AS/400.
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.
IFSFileInputStream
public IFSFileInputStream(AS400 system,
IFSJavaFile 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: IOException
- If an error occurs while communicating with the AS/400.
addFileListener
public void addFileListener(FileListener listener)
- Adds a file listener to receive file events from this IFSFileInputStream.
- Parameters:
- listener - The file listener.
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
- Adds a property change listener.
- Parameters:
- listener - The property change listener to add.
addVetoableChangeListener
public void addVetoableChangeListener(VetoableChangeListener listener)
- Adds a vetoable change listener.
- Parameters:
- listener - The vetoable change listener to add.
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: IOException
- If an error occurs while communicating with the AS/400.
- Overrides:
- available in class InputStream
close
public void close() throws IOException
- Closes this file input stream and releases any system resources associated
with the stream.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
- Overrides:
- close in class InputStream
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
getFD
public final IFSFileDescriptor getFD() throws IOException
- Returns the opaque file descriptor associated with this stream.
- Returns:
- The file descriptor object associated with this stream.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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.
getShareOption
public int getShareOption()
- Returns the share option for this object.
- Returns:
- The share option.
getSystem
public AS400 getSystem()
- Returns the AS400 system object for this file input stream.
- Returns:
- The AS400 system object.
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: IOException
- If an error occurs while communicating with the AS/400.
- See Also:
- IFSKey, unlock
open
protected void open() throws IOException
- Opens the specified file.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
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: IOException
- If an error occurs while communicating with the AS/400.
- Overrides:
- read in class InputStream
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: IOException
- If an error occurs while communicating with the AS/400.
- Overrides:
- read in class InputStream
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: IOException
- If an error occurs while communicating with the AS/400.
- Overrides:
- read in class InputStream
removeFileListener
public void removeFileListener(FileListener listener)
- Removes a file listener so that it no longer receives file events from
this IFSFileInputStream.
- Parameters:
- listener - The file listener .
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
- Removes a property change listener.
- Parameters:
- listener - The property change listener to remove.
removeVetoableChangeListener
public void removeVetoableChangeListener(VetoableChangeListener listener)
- Removes a vetoable change listener.
- Parameters:
- listener - The vetoable change listener to remove.
rewind
public void rewind()
- Rewinds the input stream. After this call, the stream will read from the beginning.
setFD
public void setFD(IFSFileDescriptor fd) throws PropertyVetoException
- Sets the file descriptor.
- Parameters:
- fd - The file descriptor.
- Throws: PropertyVetoException
- If the change is vetoed.
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.
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.
setSystem
public void setSystem(AS400 system) throws PropertyVetoException
- Sets the system.
The system cannot be changed once a connection is made to the server.
- Parameters:
- system - The AS/400 system object.
- Throws: PropertyVetoException
- If the change is vetoed.
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: IOException
- If an error occurs while communicating with the AS/400.
- Overrides:
- skip in class InputStream
unlock
public void unlock(IFSKey key) throws IOException
- Undoes a lock on this file.
- Parameters:
- key - The key for the lock.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
- See Also:
- IFSKey, lock
All Packages Class Hierarchy This Package Previous Next Index