public class IFSFileInputStream
extends java.io.InputStream
implements java.io.Serializable
// 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();
Note on the use of IFS classes when accessing QSYS files:
The IFS classes are of limited usefulness when accessing formatted
file objects under QSYS, such as physical files and save files.
The IFS classes perform their work via datastream
requests that are sent to the "File Server" job on the IBM i system.
The File Server has no awareness of, or respect for, file record structure.
When accessing QSYS file objects, consider the use of other classes such as
SequentialFile
, KeyedFile
, and
SaveFile
.
Modifier and Type | Field and Description |
---|---|
protected IFSFileDescriptor |
fd_ |
static int |
SHARE_ALL
Share option that allows read and write access by other users.
|
static int |
SHARE_NONE
Share option that does not allow read or write access by other users.
|
static int |
SHARE_READERS
Share option that allows only read access by other users.
|
static int |
SHARE_WRITERS
Share option that allows only write access by other users.
|
Constructor and Description |
---|
IFSFileInputStream()
Constructs an IFSFileInputStream.
|
IFSFileInputStream(AS400 system,
IFSFile file,
int shareOption)
Deprecated.
Use IFSFileInputStream(IFSFile, int) instead.
|
IFSFileInputStream(AS400 system,
IFSJavaFile file,
int shareOption)
Deprecated.
Use IFSFileInputStream(IFSJavaFile, int) instead.
|
IFSFileInputStream(AS400 system,
java.lang.String name)
Constructs an IFSFileInputStream.
|
IFSFileInputStream(AS400 system,
java.lang.String name,
int shareOption)
Constructs an IFSFileInputStream.
|
IFSFileInputStream(IFSFile file)
Creates a file input stream to read from the file specified by file.
|
IFSFileInputStream(IFSFileDescriptor fd)
Creates a file input stream to read from file descriptor fd.
|
IFSFileInputStream(IFSFile file,
int shareOption)
Creates a file input stream to read from the file specified by file.
|
IFSFileInputStream(IFSJavaFile file)
Creates a file input stream to read from the file specified by file.
|
IFSFileInputStream(IFSJavaFile file,
int shareOption)
Creates a file input stream to read from the file specified by file.
|
Modifier and Type | Method and Description |
---|---|
void |
addFileListener(FileListener listener)
Adds a file listener to receive file events from this IFSFileInputStream.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property change listener.
|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a vetoable change listener.
|
int |
available()
Returns the number of bytes that can be read from this file input stream.
|
void |
close()
Closes this file input stream and releases any system resources associated
with the stream.
|
protected void |
finalize()
Ensures that the file input stream is closed when there are no more
references to it.
|
IFSFileDescriptor |
getFD()
Returns the opaque file descriptor associated with this stream.
|
java.lang.String |
getPath()
Returns the integrated file system path name of the object represented by this IFSFileInputStream object.
|
int |
getShareOption()
Returns the share option for this object.
|
AS400 |
getSystem()
Returns the AS400 system object for this file input stream.
|
IFSKey |
lock(int length)
Deprecated.
Replaced by
lock(long) |
IFSKey |
lock(long length)
Places a lock on the file at the current position for the specified
number of bytes.
|
protected void |
open()
Opens the specified file.
|
int |
read()
Reads the next byte of data from this input stream.
|
int |
read(byte[] data)
Reads up to data.length bytes of data from this input stream into
data.
|
int |
read(byte[] data,
int dataOffset,
int length)
Reads up to length bytes of data from this input stream into data, starting at the array offset dataOffset.
|
void |
removeFileListener(FileListener listener)
Removes a file listener so that it no longer receives file events from
this IFSFileInputStream.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property change listener.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes a vetoable change listener.
|
void |
reset()
Rewinds the input stream.
|
void |
rewind()
Deprecated.
Use reset() instead.
|
void |
setFD(IFSFileDescriptor fd)
Sets the file descriptor.
|
void |
setPath(java.lang.String path)
Sets the integrated file system path name.
|
void |
setShareOption(int shareOption)
Sets the share option.
|
void |
setSystem(AS400 system)
Sets the system.
|
long |
skip(long bytesToSkip)
Skips over the next bytesToSkip bytes in the file input stream.
|
void |
unlock(IFSKey key)
Undoes a lock on this file.
|
public static final int SHARE_ALL
public static final int SHARE_NONE
public static final int SHARE_READERS
public static final int SHARE_WRITERS
protected IFSFileDescriptor fd_
public IFSFileInputStream()
public IFSFileInputStream(AS400 system, java.lang.String name) throws AS400SecurityException, java.io.IOException
system
- The AS400 that contains the file.name
- The integrated file system name.AS400SecurityException
- If a security or authority error occurs.java.io.IOException
- If an error occurs while communicating with the system.public IFSFileInputStream(AS400 system, java.lang.String name, int shareOption) throws AS400SecurityException, java.io.IOException
system
- The system that contains the file.name
- The integrated file system name.shareOption
- Indicates how users can access the file. AS400SecurityException
- If a security or authority error occurs.java.io.IOException
- If an error occurs while communicating with the system.public IFSFileInputStream(IFSFile file) throws AS400SecurityException, java.io.IOException
file
- The file to be opened for reading.AS400SecurityException
- If a security or authority error occurs.java.io.IOException
- If an error occurs while communicating with the system.public IFSFileInputStream(AS400 system, IFSFile file, int shareOption) throws AS400SecurityException, java.io.IOException
system
- The system that contains the file.file
- The file to be opened for reading.shareOption
- Indicates how users can access the file. AS400SecurityException
- If a security or authority error occurs.java.io.IOException
- If an error occurs while communicating with the system.public IFSFileInputStream(IFSFile file, int shareOption) throws AS400SecurityException, java.io.IOException
file
- The file to be opened for reading.shareOption
- Indicates how users can access the file. AS400SecurityException
- If a security or authority error occurs.java.io.IOException
- If an error occurs while communicating with the system.public IFSFileInputStream(IFSFileDescriptor fd)
fd
- The file descriptor to be opened for reading.public IFSFileInputStream(IFSJavaFile file) throws AS400SecurityException, java.io.IOException
file
- The file to be opened for reading.AS400SecurityException
- If a security or authority error occurs.java.io.IOException
- If an error occurs while communicating with the system.public IFSFileInputStream(AS400 system, IFSJavaFile file, int shareOption) throws AS400SecurityException, java.io.IOException
system
- The system that contains the file.file
- The file to be opened for reading.shareOption
- Indicates how users can access the file. AS400SecurityException
- If a security or authority error occurs.java.io.IOException
- If an error occurs while communicating with the system.public IFSFileInputStream(IFSJavaFile file, int shareOption) throws AS400SecurityException, java.io.IOException
file
- The file to be opened for reading.shareOption
- Indicates how users can access the file. AS400SecurityException
- If a security or authority error occurs.java.io.IOException
- If an error occurs while communicating with the system.public void addFileListener(FileListener listener)
listener
- The file listener.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The property change listener to add.public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The vetoable change listener to add.public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
- If an error occurs while communicating with the system.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.InputStream
java.io.IOException
- If an error occurs while communicating with the system.protected void finalize() throws java.io.IOException
finalize
in class java.lang.Object
java.io.IOException
- If an error occurs while communicating with the system.public final IFSFileDescriptor getFD() throws java.io.IOException
java.io.IOException
- If an error occurs while communicating with the system.public java.lang.String getPath()
public int getShareOption()
public AS400 getSystem()
public IFSKey lock(int length) throws java.io.IOException
lock(long)
length
- The number of bytes to lock.ExtendedIOException
- If the specified bytes are already locked by another process.java.io.IOException
- If an error occurs while communicating with the system.IFSKey
,
unlock(com.ibm.as400.access.IFSKey)
public IFSKey lock(long length) throws java.io.IOException
length
- The number of bytes to lock.java.io.IOException
- If an error occurs while communicating with the system.IFSKey
,
unlock(com.ibm.as400.access.IFSKey)
protected void open() throws java.io.IOException
java.io.IOException
- If an error occurs while communicating with the system.public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
- If an error occurs while communicating with the system.public int read(byte[] data) throws java.io.IOException
read
in class java.io.InputStream
data
- The buffer into which data is read.java.io.IOException
- If an error occurs while communicating with the system.public int read(byte[] data, int dataOffset, int length) throws java.io.IOException
read
in class java.io.InputStream
data
- The buffer into which the data is read.dataOffset
- The start offset of the data in the buffer.length
- The maximum number of bytes to readjava.io.IOException
- If an error occurs while communicating with the system.public void removeFileListener(FileListener listener)
listener
- The file listener .public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The property change listener to remove.public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The vetoable change listener to remove.public void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException
public void rewind()
public void setFD(IFSFileDescriptor fd) throws java.beans.PropertyVetoException
fd
- The file descriptor.java.beans.PropertyVetoException
- If the change is vetoed.public void setPath(java.lang.String path) throws java.beans.PropertyVetoException
path
- The absolute integrated file system path name.java.beans.PropertyVetoException
- If the change is vetoed.public void setShareOption(int shareOption) throws java.beans.PropertyVetoException
shareOption
- Indicates how users can access the file. java.beans.PropertyVetoException
- If the change is vetoed.public void setSystem(AS400 system) throws java.beans.PropertyVetoException
system
- The system object.java.beans.PropertyVetoException
- If the change is vetoed.public long skip(long bytesToSkip) throws java.io.IOException
skip
in class java.io.InputStream
bytesToSkip
- The number of bytes to skip.java.io.IOException
- If an error occurs while communicating with the system.public void unlock(IFSKey key) throws java.io.IOException
key
- The key for the lock.java.io.IOException
- If an error occurs while communicating with the system.IFSKey
,
lock(long)