com.ibm.as400.access

Class IFSRandomAccessFile

  • All Implemented Interfaces:
    DataInput, DataOutput, Serializable


    public class IFSRandomAccessFile
    extends Object
    implements DataInput, DataOutput, Serializable
    Supports read and write access to integrated file system objects. The position at which the next access occurs can be modified. This class offers methods that allow specified mode access of read-only, write-only, or read-write.
    IFSRandomAccessFile objects are capable of generating file events that call the following FileListener methods: fileClosed, fileModified, and fileOpened.
    The following example illustrates the use of IFSRandomAccessFile:
     // Work with /Dir/File on the system eniac.
     AS400 as400 = new AS400("eniac");
     IFSRandomAccessFile file = new IFSRandomAccessFile(as400, "/Dir/File", "rw");
     // Determine the file length.
     long length = file.length();
     // Lock the first 11 bytes.
     IFSKey key = file.lock(0, 11);
     // Write a string to the file.
     file.writeChars("Hello world");
     // Read the string we just wrote.
     file.seek(0);
     String s = file.readLine();
     // Close the file.
     file.close();
     
    See Also:
    FileEvent, addFileListener(com.ibm.as400.access.FileListener), removeFileListener(com.ibm.as400.access.FileListener), Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int FAIL_OR_CREATE
      File existence option that indicates that the request is either to fail if the file exists or is to create the file if it does not exist.
      static int OPEN_OR_CREATE
      File existence option that indicates that the file is either to be opened if it exists or is to be created if it does not exist.
      static int OPEN_OR_FAIL
      File existence option that indicates that the file is either to be opened if it exists or that the request is to fail if the file does not exist.
      static int REPLACE_OR_CREATE
      File existence option that indicates that the file is either to be replaced if it exists or is to be created if it does not exist.
      static int REPLACE_OR_FAIL
      File existence option that indicates that the file is either to be replaced if it exists or that the request is to fail if the file does not exist.
      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.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addFileListener(FileListener listener)
      Adds a file listener to receive file events from this IFSRandomAccessFile.
      void addPropertyChangeListener(PropertyChangeListener listener)
      Adds a property change listener.
      void addVetoableChangeListener(VetoableChangeListener listener)
      Adds a vetoable change listener.
      void close()
      Closes this random access file stream and releases any system resources associated with the stream.
      protected void finalize()
      Ensures that the stream is closed when there are no more references to it.
      void flush()
      Forces any buffered output bytes to be written.
      int getExistenceOption()
      Returns the existence option for this object.
      IFSFileDescriptor getFD()
      Returns a file descriptor associated with this stream.
      long getFilePointer()
      Returns the current offset in this file.
      String getPath()
      Returns the integrated file system path name of the object represented by this IFSRandomAccessFile.
      int getShareOption()
      Returns the share option for this object.
      AS400 getSystem()
      Returns the AS400 system object for this stream.
      long length()
      Returns the file length.
      IFSKey lock(int offset, int length)
      Deprecated. 
      Replaced by lock(long,long)
      IFSKey lock(long offset, long length)
      Places a lock on the file at the specified bytes.
      int read()
      Reads the next byte of data from this file.
      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.
      boolean readBoolean()
      Reads a boolean from this file.
      byte readByte()
      Reads a signed 8-bit value from this file.
      char readChar()
      Reads a Unicode character from this file.
      double readDouble()
      Reads a double from this file.
      float readFloat()
      Reads a float from this file.
      void readFully(byte[] data)
      Reads data.length bytes from this file into the byte array.
      void readFully(byte[] data, int dataOffset, int length)
      Reads exactly length bytes from this file into the byte array.
      int readInt()
      Reads a signed 32-bit integer from this file.
      String readLine()
      Reads the next line of text from this file.
      long readLong()
      Reads a signed 64-bit integer from this file.
      short readShort()
      Reads a signed 16-bit integer from this file.
      int readUnsignedByte()
      Reads an unsigned 8-bit number from this file.
      int readUnsignedShort()
      Reads an unsigned 16-bit number from this file.
      String readUTF()
      Reads in a string from this file.
      void removeFileListener(FileListener listener)
      Removes a file listener so that it no longer receives file events from this IFSRandomAccessFile.
      void removePropertyChangeListener(PropertyChangeListener listener)
      Removes a property change listener.
      void removeVetoableChangeListener(VetoableChangeListener listener)
      Removes a vetoable change listener.
      void seek(long position)
      Sets the offset, from the beginning of this file, at which the next read or write occurs.
      void setExistenceOption(int existenceOption)
      Sets the existence option.
      void setLength(int length)
      Deprecated. 
      Replaced by setLength(long)
      void setLength(long length)
      Sets the length of the file represented by this object.
      void setMode(String mode)
      Sets the access mode.
      void setPath(String path)
      Sets the file path.
      void setShareOption(int shareOption)
      Sets the share option.
      void setSystem(AS400 system)
      Sets the system.
      int skipBytes(int bytesToSkip)
      Deprecated. 
      Replaced by skipBytes(long)
      long skipBytes(long bytesToSkip)
      Skips over the next bytesToSkip bytes in the stream.
      void unlock(IFSKey key)
      Undoes a lock on this file.
      void write(byte[] data)
      Writes data.length bytes of data from the byte array data to this file output stream.
      void write(byte[] data, int dataOffset, int length)
      Writes length bytes from the byte array data, starting at dataOffset, to this file.
      void write(int b)
      Writes the specified byte to this file.
      void writeBoolean(boolean value)
      Writes a boolean to the file as a one-byte value.
      void writeByte(int value)
      Writes a byte to the file as a one-byte value.
      void writeBytes(String s)
      Writes out the string to the file as a sequence of bytes.
      void writeChar(int value)
      Writes a char to the file as a two-byte value, high byte first.
      void writeChars(String s)
      Writes a string to the file as a sequence of characters.
      void writeDouble(double value)
      Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the file as an eight-byte quantity, high-byte first.
      void writeFloat(float value)
      Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the file as a four-byte quantity, high-byte first.
      void writeInt(int value)
      Writes an int to the file as four bytes, high-byte first.
      void writeLong(long value)
      Writes a long to the file as eight bytes, high-byte first.
      void writeShort(int value)
      Writes a short to the file as two bytes, high-byte first.
      void writeUTF(String s)
      Writes out a string to the file using UTF-8 encoding in a machine-independent manner.
    • Field Detail

      • SHARE_ALL

        public static final int SHARE_ALL
        Share option that allows read and write access by other users.
        See Also:
        Constant Field Values
      • SHARE_NONE

        public static final int SHARE_NONE
        Share option that does not allow read or write access by other users.
        See Also:
        Constant Field Values
      • SHARE_READERS

        public static final int SHARE_READERS
        Share option that allows only read access by other users.
        See Also:
        Constant Field Values
      • SHARE_WRITERS

        public static final int SHARE_WRITERS
        Share option that allows only write access by other users.
        See Also:
        Constant Field Values
      • FAIL_OR_CREATE

        public static final int FAIL_OR_CREATE
        File existence option that indicates that the request is either to fail if the file exists or is to create the file if it does not exist.
        See Also:
        Constant Field Values
      • OPEN_OR_CREATE

        public static final int OPEN_OR_CREATE
        File existence option that indicates that the file is either to be opened if it exists or is to be created if it does not exist.
        See Also:
        Constant Field Values
      • OPEN_OR_FAIL

        public static final int OPEN_OR_FAIL
        File existence option that indicates that the file is either to be opened if it exists or that the request is to fail if the file does not exist.
        See Also:
        Constant Field Values
      • REPLACE_OR_CREATE

        public static final int REPLACE_OR_CREATE
        File existence option that indicates that the file is either to be replaced if it exists or is to be created if it does not exist.
        See Also:
        Constant Field Values
      • REPLACE_OR_FAIL

        public static final int REPLACE_OR_FAIL
        File existence option that indicates that the file is either to be replaced if it exists or that the request is to fail if the file does not exist.
        See Also:
        Constant Field Values
    • Constructor Detail

      • IFSRandomAccessFile

        public IFSRandomAccessFile()
        Constructs an IFSRandomAccessFile object. It is a default random access file. Other readers and writers are allowed to access the file.
      • IFSRandomAccessFile

        public IFSRandomAccessFile(AS400 system,
                           String name,
                           String mode)
                            throws AS400SecurityException,
                                   IOException
        Constructs an IFSRandomAccessFile object. It uses the specified system name, file name, and mode. If the mode is r, the file is opened if it exists; otherwise, an IOException is thrown. If the mode is rw or w, the file is opened if it exists; otherwise, the file is created. Other readers and writers are allowed to access the file.
        Parameters:
        system - The AS400 that contains the file.
        name - The file name.
        mode - The access mode
        • "r" read only
        • "w" write only
        • "rw" read/write
        Throws:
        AS400SecurityException - If a security or authority error occurs.
        IOException - If an error occurs while communicating with the system.
      • IFSRandomAccessFile

        public IFSRandomAccessFile(AS400 system,
                           String name,
                           String mode,
                           int shareOption,
                           int existenceOption)
                            throws AS400SecurityException,
                                   IOException
        Constructs an IFSRandomAccessFile object. It uses the specified system name, file name, mode, share option, and existence option.
        Parameters:
        system - The AS400 that contains the file.
        name - The file name.
        mode - The acess mode
        • "r" read only
        • "w" write only
        • "rw" read/write
        shareOption - Indicates how users can access the file.
        • SHARE_ALL Share access with readers and writers
        • SHARE_NONE Share access with none
        • SHARE_READERS Share access with readers
        • SHARE_WRITERS Share access with writers
        existenceOption - Indicates if the file should be created, opened or if the request should fail based on the existence of the file.
        • FAIL_OR_CREATE Fail if exists; create if not
        • OPEN_OR_CREATE Open if exists; create if not
        • OPEN_OR_FAIL Open if exists; fail if not
        • REPLACE_OR_CREATE Replace if exists; create if not
        • REPLACE_OR_FAIL Replace if exists; fail if not
        Throws:
        AS400SecurityException - If a security or authority error occurs.
        IOException - If an error occurs while communicating with the system.
      • IFSRandomAccessFile

        public IFSRandomAccessFile(AS400 system,
                           IFSFile file,
                           String mode,
                           int shareOption,
                           int existenceOption)
                            throws AS400SecurityException,
                                   IOException
        Deprecated. Use IFSRandomAccessFile(IFSFile,String,int,int) instead.
        Constructs an IFSRandomAccessFile object. It uses the specified system name, file name, mode, share option, and existence option.
        Parameters:
        system - The AS400 that contains the file.
        file - The file to access.
        mode - The access mode
        • "r" read only
        • "w" write only
        • "rw" read/write
        shareOption - Indicates how other user's can access the file.
        • SHARE_ALL Share access with readers and writers
        • SHARE_NONE Share access with none
        • SHARE_READERS Share access with readers
        • SHARE_WRITERS Share access with writers
        existenceOption - Indicates if the file should be created, opened or if the request should fail based on the existence of the file.
        • FAIL_OR_CREATE Fail if exists; create if not
        • OPEN_OR_CREATE Open if exists; create if not
        • OPEN_OR_FAIL Open if exists; fail if not
        • REPLACE_OR_CREATE Replace if exists; create if not
        • REPLACE_OR_FAIL Replace if exists; fail if not
        Throws:
        AS400SecurityException - If a security or authority error occurs.
        IOException - If an error occurs while communicating with the system.
      • IFSRandomAccessFile

        public IFSRandomAccessFile(IFSFile file,
                           String mode,
                           int shareOption,
                           int existenceOption)
                            throws AS400SecurityException,
                                   IOException
        Constructs an IFSRandomAccessFile object. It uses the specified file, mode, share option, and existence option.
        Parameters:
        file - The file to access.
        mode - The access mode
        • "r" read only
        • "w" write only
        • "rw" read/write
        shareOption - Indicates how other user's can access the file.
        • SHARE_ALL Share access with readers and writers
        • SHARE_NONE Share access with none
        • SHARE_READERS Share access with readers
        • SHARE_WRITERS Share access with writers
        existenceOption - Indicates if the file should be created, opened or if the request should fail based on the existence of the file.
        • FAIL_OR_CREATE Fail if exists; create if not
        • OPEN_OR_CREATE Open if exists; create if not
        • OPEN_OR_FAIL Open if exists; fail if not
        • REPLACE_OR_CREATE Replace if exists; create if not
        • REPLACE_OR_FAIL Replace if exists; fail if not
        Throws:
        AS400SecurityException - If a security or authority error occurs.
        IOException - If an error occurs while communicating with the system.

    • Method Detail

      • addFileListener

        public void addFileListener(FileListener listener)
        Adds a file listener to receive file events from this IFSRandomAccessFile.
        Parameters:
        listener - The file listener.
      • addPropertyChangeListener

        public void addPropertyChangeListener(PropertyChangeListener listener)
        Adds a property change listener.
        Parameters:
        listener - The property change listener to add.
      • addVetoableChangeListener

        public void addVetoableChangeListener(VetoableChangeListener listener)
        Adds a vetoable change listener.
        Parameters:
        listener - The vetoable change listener to add.
      • close

        public void close()
                   throws IOException
        Closes this random access file stream and releases any system resources associated with the stream. This will not close the connection to the Host Server job held by the associated AS400 object.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • finalize

        protected void finalize()
                         throws IOException
        Ensures that the stream is closed when there are no more references to it.
        Overrides:
        finalize in class Object
        Throws:
        IOException - If an error occurs while communicating with the system.
      • flush

        public void flush()
                   throws IOException
        Forces any buffered output bytes to be written.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • getExistenceOption

        public int getExistenceOption()
        Returns the existence option for this object.
        Returns:
        The existence option.
      • getFD

        public final IFSFileDescriptor getFD()
                                      throws IOException
        Returns a file descriptor associated with this stream.
        Returns:
        The file descriptor associated with this stream
        Throws:
        IOException - If an error occurs while communicating with the system.
      • getFilePointer

        public long getFilePointer()
                            throws IOException
        Returns the current offset in this file.
        Returns:
        The offset from the beginning of the file, in bytes, at which the next read or write occurs.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • getPath

        public String getPath()
        Returns the integrated file system path name of the object represented by this IFSRandomAccessFile.
        Returns:
        The absolute path name of the object.
      • getShareOption

        public int getShareOption()
        Returns the share option for this object.
        Returns:
        The share option.
      • getSystem

        public AS400 getSystem()
        Returns the AS400 system object for this stream.
        Returns:
        The AS400 system object.
      • length

        public long length()
                    throws IOException
        Returns the file length.
        Returns:
        The file length, in bytes.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • lock

        public IFSKey lock(int offset,
                  int length)
                    throws IOException
        Deprecated. Replaced by lock(long,long)
        Places a lock on the file at the specified bytes. Note: This method is not supported for files under QSYS.
        Parameters:
        offset - The first byte of the file to lock (zero is the first byte).
        length - The number of bytes to lock.
        Returns:
        A key for undoing this lock.
        Throws:
        IOException - If an error occurs while communicating with the system.
        See Also:
        IFSKey, unlock(com.ibm.as400.access.IFSKey)
      • lock

        public IFSKey lock(long offset,
                  long length)
                    throws IOException
        Places a lock on the file at the specified bytes. Note: This method is not supported for files under QSYS.
        Parameters:
        offset - The first byte of the file to lock (zero is the first byte).
        length - The number of bytes to lock.
        Returns:
        A key for undoing this lock.
        Throws:
        IOException - If an error occurs while communicating with the system.
        See Also:
        IFSKey, unlock(com.ibm.as400.access.IFSKey)
      • read

        public int read()
                 throws IOException
        Reads the next byte of data from this file.
        Returns:
        The next byte of data, or -1 if the end of file is reached.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • read

        public int read(byte[] data)
                 throws IOException
        Reads up to data.length bytes of data from this input stream into data.
        Parameters:
        data - The buffer into which data is read.
        Returns:
        The total number of bytes read into the buffer, or -1 if there is no more data because the end of file has been reached.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • read

        public int read(byte[] data,
               int dataOffset,
               int length)
                 throws IOException
        Reads up to length bytes of data from this input stream into data, starting at the array offset dataOffset.
        Parameters:
        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 read.
        Returns:
        The total number of bytes read into the buffer, or -1 if there is no more data because the end of file has been reached.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readBoolean

        public final boolean readBoolean()
                                  throws IOException
        Reads a boolean from this file. This method reads a single byte from the file. A value of 0 represents false. Any other value represents true.
        Specified by:
        readBoolean in interface DataInput
        Returns:
        The boolean value read.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readByte

        public final byte readByte()
                            throws IOException
        Reads a signed 8-bit value from this file. This method reads a single byte from the file.
        Specified by:
        readByte in interface DataInput
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readChar

        public final char readChar()
                            throws IOException
        Reads a Unicode character from this file. Two bytes are read from the file.
        Specified by:
        readChar in interface DataInput
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readDouble

        public final double readDouble()
                                throws IOException
        Reads a double from this file. This method reads a long value as if by the readLong method and then converts that long to a double using the longBitsToDouble method in class Double.
        Specified by:
        readDouble in interface DataInput
        Returns:
        The next eight bytes of this file, interpreted as a double.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readFloat

        public final float readFloat()
                              throws IOException
        Reads a float from this file. This method reads an int value as if by the readInt method and then converts that int to a float using the intBitsToFloat method in class Float.
        Specified by:
        readFloat in interface DataInput
        Returns:
        The next four bytes of this file, interpreted as a float.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readFully

        public final void readFully(byte[] data)
                             throws IOException
        Reads data.length bytes from this file into the byte array. This method reads repeatedly from the file until all the bytes are read or an exception is thrown.
        Specified by:
        readFully in interface DataInput
        Parameters:
        data - The buffer into which data is read.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readFully

        public final void readFully(byte[] data,
                     int dataOffset,
                     int length)
                             throws IOException
        Reads exactly length bytes from this file into the byte array. This method reads repeatedly from the file until all the bytes are read or an exception is thrown.
        Specified by:
        readFully in interface DataInput
        Parameters:
        data - The buffer into which data is read.
        dataOffset - The start offset in the data buffer.
        length - The number of bytes to read.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readInt

        public final int readInt()
                          throws IOException
        Reads a signed 32-bit integer from this file.
        Specified by:
        readInt in interface DataInput
        Returns:
        The next four bytes of this file, interpreted as an integer.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readLine

        public final String readLine()
                              throws IOException
        Reads the next line of text from this file. This method successively reads bytes from the file until it reaches the end of a line of text. A line of text is terminated by a carriage return character (\r), a newline character (\n), a carriage return character immediately followed by a newline character, or the end of the input stream. The line-terminating characters, if any, are included as part of the string returned.
        Specified by:
        readLine in interface DataInput
        Returns:
        The next line of text from this file.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readLong

        public final long readLong()
                            throws IOException
        Reads a signed 64-bit integer from this file.
        Specified by:
        readLong in interface DataInput
        Returns:
        The next eight bytes of the file, interpreted as a long.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readShort

        public final short readShort()
                              throws IOException
        Reads a signed 16-bit integer from this file.
        Specified by:
        readShort in interface DataInput
        Returns:
        The next two bytes of this file, interpreted as a short.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readUnsignedByte

        public final int readUnsignedByte()
                                   throws IOException
        Reads an unsigned 8-bit number from this file. This method reads a byte from this file and returns that byte.
        Specified by:
        readUnsignedByte in interface DataInput
        Returns:
        The next byte of this file, interpreted as an unsigned 8-bit number.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readUnsignedShort

        public final int readUnsignedShort()
                                    throws IOException
        Reads an unsigned 16-bit number from this file.
        Specified by:
        readUnsignedShort in interface DataInput
        Returns:
        The next two bytes of this file, interpreted as an unsigned 16-bit number.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • readUTF

        public final String readUTF()
                             throws IOException
        Reads in a string from this file. The string has been encoded using a modified UTF-8 format.
        The first two bytes are read as if by readUnsignedShort. This values gives the number of following bytes that are in the encoded string (note, not the length of the resulting string). The following bytes are then interpreted as bytes encoding characters in the UTF-8 format and are converted into characters.
        Specified by:
        readUTF in interface DataInput
        Returns:
        A Unicode string.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • removeFileListener

        public void removeFileListener(FileListener listener)
        Removes a file listener so that it no longer receives file events from this IFSRandomAccessFile.
        Parameters:
        listener - The file listener.
      • removePropertyChangeListener

        public void removePropertyChangeListener(PropertyChangeListener listener)
        Removes a property change listener.
        Parameters:
        listener - The property change listener to remove.
      • removeVetoableChangeListener

        public void removeVetoableChangeListener(VetoableChangeListener listener)
        Removes a vetoable change listener.
        Parameters:
        listener - The vetoable change listener to remove.
      • seek

        public void seek(long position)
                  throws IOException
        Sets the offset, from the beginning of this file, at which the next read or write occurs.
        Parameters:
        position - The absolute position of the file pointer.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • setExistenceOption

        public void setExistenceOption(int existenceOption)
                                throws PropertyVetoException
        Sets the existence option.
        Parameters:
        existenceOption - Indicates if the file should be created, opened or if the request should fail based on the existence of the file.
        • FAIL_OR_CREATE Fail if exists; create if not
        • OPEN_OR_CREATE Open if exists; create if not
        • OPEN_OR_FAIL Open if exists; fail if not
        • REPLACE_OR_CREATE Replace if exists; create if not
        • REPLACE_OR_FAIL Replace if exists; fail if not
        Throws:
        PropertyVetoException - If the change is vetoed.
      • setLength

        public void setLength(int length)
                       throws IOException
        Deprecated. Replaced by setLength(long)
        Sets the length of the file represented by this object. The file can be made larger or smaller. If the file is made larger, the contents of the new bytes of the file are undetermined.
        Parameters:
        length - The new length, in bytes.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • setLength

        public void setLength(long length)
                       throws IOException
        Sets the length of the file represented by this object. The file can be made larger or smaller. If the file is made larger, the contents of the new bytes of the file are undetermined.
        Parameters:
        length - The new length, in bytes.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • setPath

        public void setPath(String path)
                     throws PropertyVetoException
        Sets the file path. Sets the integrated file system path name.
        Parameters:
        path - The absolute integrated file system path name.
        Throws:
        PropertyVetoException - If the change is vetoed.
      • setShareOption

        public void setShareOption(int shareOption)
                            throws PropertyVetoException
        Sets the share option.
        Parameters:
        shareOption - Indicates how users can access the file.
        • SHARE_ALL Share access with readers and writers
        • SHARE_NONE Share access with none
        • SHARE_READERS Share access with readers
        • SHARE_WRITERS Share access with writers
        .
        Throws:
        PropertyVetoException - If the change is vetoed.
      • setSystem

        public void setSystem(AS400 system)
                       throws PropertyVetoException
        Sets the system. The system cannot be changed once a connection is made to the system.
        Parameters:
        system - The system object.
        Throws:
        PropertyVetoException - If the change is vetoed.
      • skipBytes

        public int skipBytes(int bytesToSkip)
                      throws IOException
        Deprecated. Replaced by skipBytes(long)
        Skips over the next bytesToSkip bytes in the stream.
        Specified by:
        skipBytes in interface DataInput
        Parameters:
        bytesToSkip - The number of bytes to skip.
        Returns:
        The number of bytes skipped.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • skipBytes

        public long skipBytes(long bytesToSkip)
                       throws IOException
        Skips over the next bytesToSkip bytes in the stream.
        Parameters:
        bytesToSkip - The number of bytes to skip.
        Returns:
        The number of bytes skipped.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • unlock

        public void unlock(IFSKey key)
                    throws IOException
        Undoes a lock on this file. Note: This method is not supported for files under QSYS.
        Parameters:
        key - The key for the lock.
        Throws:
        IOException - If an error occurs while communicating with the system.
        See Also:
        IFSKey, lock(int, int)
      • write

        public void write(int b)
                   throws IOException
        Writes the specified byte to this file.
        Specified by:
        write in interface DataOutput
        Parameters:
        b - The byte to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • write

        public void write(byte[] data)
                   throws IOException
        Writes data.length bytes of data from the byte array data to this file output stream.
        Specified by:
        write in interface DataOutput
        Parameters:
        data - The data to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • write

        public void write(byte[] data,
                 int dataOffset,
                 int length)
                   throws IOException
        Writes length bytes from the byte array data, starting at dataOffset, to this file.
        Specified by:
        write in interface DataOutput
        Parameters:
        data - The data.
        dataOffset - The start offset in the data.
        length - The number of bytes to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeBoolean

        public final void writeBoolean(boolean value)
                                throws IOException
        Writes a boolean to the file as a one-byte value. The value true is written out as the value (byte)1. The value false is written out as the value (byte)0.
        Specified by:
        writeBoolean in interface DataOutput
        Parameters:
        value - The value to be written.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeByte

        public final void writeByte(int value)
                             throws IOException
        Writes a byte to the file as a one-byte value.
        Specified by:
        writeByte in interface DataOutput
        Parameters:
        value - The value to be written as a byte.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeBytes

        public final void writeBytes(String s)
                              throws IOException
        Writes out the string to the file as a sequence of bytes. Each character in the string is written out, in sequence, by discarding its high eight bits. Because this method discards eight bits of data, it should not be used to write double-byte characters. Use writeChars(String) instead.
        Specified by:
        writeBytes in interface DataOutput
        Parameters:
        s - The bytes to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
        See Also:
        writeChars(String)
      • writeChar

        public final void writeChar(int value)
                             throws IOException
        Writes a char to the file as a two-byte value, high byte first.
        Specified by:
        writeChar in interface DataOutput
        Parameters:
        value - A character value to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeChars

        public final void writeChars(String s)
                              throws IOException
        Writes a string to the file as a sequence of characters. Each character is written to the file as if by the writeChar method.
        Specified by:
        writeChars in interface DataOutput
        Parameters:
        s - A String to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeDouble

        public final void writeDouble(double value)
                               throws IOException
        Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the file as an eight-byte quantity, high-byte first.
        Specified by:
        writeDouble in interface DataOutput
        Parameters:
        value - The value to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeFloat

        public final void writeFloat(float value)
                              throws IOException
        Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the file as a four-byte quantity, high-byte first.
        Specified by:
        writeFloat in interface DataOutput
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeInt

        public final void writeInt(int value)
                            throws IOException
        Writes an int to the file as four bytes, high-byte first.
        Specified by:
        writeInt in interface DataOutput
        Parameters:
        value - The int to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeLong

        public final void writeLong(long value)
                             throws IOException
        Writes a long to the file as eight bytes, high-byte first.
        Specified by:
        writeLong in interface DataOutput
        Parameters:
        value - The value to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeShort

        public final void writeShort(int value)
                              throws IOException
        Writes a short to the file as two bytes, high-byte first.
        Specified by:
        writeShort in interface DataOutput
        Parameters:
        value - The value to write.
        Throws:
        IOException - If an error occurs while communicating with the system.
      • writeUTF

        public final void writeUTF(String s)
                            throws IOException
        Writes out a string to the file using UTF-8 encoding in a machine-independent manner.
        First, two bytes are written to the file as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string. Following the length, each character of the string is output, in sequence, using the UTF-8 encoding for each character.
        Specified by:
        writeUTF in interface DataOutput
        Parameters:
        s - The string to write.
        Throws:
        IOException - If an error occurs while communicating with the system.