IFSJavaFile class

This class represents a file in the iSeries™ integrated file system and extends the java.io.File class. IFSJavaFile allows you to write files for the java.io.File interface that access iSeries integrated file systems.

IFSJavaFile

IFSJavaFile makes portable interfaces that are compatible with java.io.File and uses only the errors and exceptions that java.io.File uses. IFSJavaFile uses the security manager features from java.io.File, but unlike java.io.File, IFSJavaFile uses security features continuously.

You use IFSJavaFile with IFSFileInputStream and IFSFileOutputStream. It does not support java.io.FileInputStream and java.io.FileOutputStream.

IFSJavaFile is based on IFSFile; however, its interface is more like java.io.File than IFSFile. IFSFile is an alternative to the IFSJavaFile class.

You can get the list of files in a directory by using either the list() method or the listFiles() method:

Note: Using listFiles() means that the information in the cache eventually become stale, so you may need to refresh the data.

Example: Using IFSJavaFile

Note: Read the Code example disclaimer for important legal information.

The following example shows how to use the IFSJavaFile class:

     // Work with /Dir/File.txt on the system flash.
     AS400 as400 = new AS400("flash");
     IFSJavaFile file = new IFSJavaFile(as400, "/Dir/File.txt");

     // Determine the parent directory of the file.
     String directory = file.getParent();

     // Determine the name of the file.
     String name = file.getName();

     // Determine the file size.
     long length = file.length();

     // Determine when the file was last modified.
     Date date = new Date(file.lastModified());

     // Delete the file.
     if (file.delete() == false)
     {
       // Display the error code.
       System.err.println("Unable to delete file.");
     }

     try
     {
       IFSFileOutputStream os =
          new IFSFileOutputStream(file.getSystem(), file, IFSFileOutputStream.SHARE_ALL, false);
       byte[] data = new byte[256];
       int i = 0;
       for (; i < data.length; i++)
       {
         data[i] = (byte) i;
         os.write(data[i]);
       }
       os.close();
     }
     catch (Exception e)
     {
       System.err.println ("Exception: " + e.getMessage());
     }