IFSFileInputStream

The IFSFileInputStream class represents an input stream for reading data from a file on the server.

IFSFileInputStream

As in the IFSFile class, methods exist in IFSFileInputStream that duplicate the methods in FileInputStream from the java.io package. In addition to these methods, IFSFileInputStream has additional methods specific to iSeries™ servers. The IFSFileInputStream class allows a Java™ program to do the following:

As in FileInputStream in java.io, this class allows a Java program to read a stream of bytes from the file. The Java program reads the bytes sequentially with only the additional option of skipping bytes in the stream.

In addition to the methods in FileInputStream, IFSFileInputStream gives the Java program the following options:

Example: Using IFSFileInputStream

The following example shows how to use the IFSFileInputStream class.

                       // Create an AS400 object.
     AS400 sys = new AS400("mySystem.myCompany.com");

                       // Open a file object that
                       // represents the file.
     IFSFileInputStream aFile = new IFSFileInputStream(sys,"/mydir1/mydir2/myfile");

                       // Determine the number of bytes in
                       // the file.
     int available = aFile.available();

                       // Allocate a buffer to hold the data
     byte[] data = new byte[10240];

                       // Read the entire file 10K at a time
     for (int i = 0; i < available; i += 10240)
     {
         aFile.read(data);
     }

                       // Close the file.
     aFile.close();