File sharing mode

The Java™ program can specify a sharing mode when a file is opened. The program either allows other programs to open the file at the same time or has exclusive access to the file.

The following example shows how to specify a file sharing mode.

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

                       // Open a file object that
                       // represents the file. Since this
                       // program specifies share-none, all
                       // other open attempts fail until
                       // this instance is closed.
     IFSFileOutputStream aFile = new IFSFileOutputStream(sys,
                                                         "/mydir1/mydir2/myfile",
                                                         IFSFileOutputStream.SHARE_NONE,
                                                         false);

                       // Perform operations on the file.

                       // Close the file. Now other open
                       // requests succeed.
     aFile.close();