The IBM® Toolbox
for Java™ IFSFile
class represents an object in the IBM i integrated
file system.
The methods on IFSFile represent operations that are
done on the object as a whole. You can use IFSFileInputStream, IFSFileOutputStream,
and IFSRandomAccessFile to read and write to the file. The IFSFile
class allows the Java program to do the following:
- Determine if the object exists and is a directory or a file
- Determine if the Java program
can read from or write to a file
- Determine the length of a file
- Determine the permissions of an object and set the permissions
of an object
- Create a directory
- Delete a file or directory
- Rename a file or directory
- Get or set the last modification date of a file
- List the contents of a directory
- List the contents of a directory and save the attribute information
to a local cache
- Determine the amount of space available on the system
- Determine the type of the file object when it is in the QSYS.LIB
file system
You can get the list of files in
a directory by using either the list() method or the listFiles() method:
- The listFiles() method caches information for each file on the
initial call. After calling listFiles(), using other methods to query
file details results in better performance because the information
is retrieved from the cache. For example, calling isDirectory() on
an IFSFile object returned from listFiles() does not require a call
to the server.
- The list() method retrieves information about each file in a separate
request to the server, making it slower and more demanding of server
resources.
Note: Using listFiles() means that the information in the cache
may eventually become stale, so you may need to refresh the data by
calling listFiles() again.
Examples
The following examples show how
to use the IFSFile class: