com.ibm.as400.access

Class IFSRandomAccessFile

  • java.lang.Object
    • com.ibm.as400.access.IFSRandomAccessFile
  • All Implemented Interfaces:
    java.io.DataInput, java.io.DataOutput, java.io.Serializable


    public class IFSRandomAccessFile
    extends java.lang.Object
    implements java.io.DataInput, java.io.DataOutput, java.io.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.
    • Constructor Summary

      Constructors 
      Constructor and Description
      IFSRandomAccessFile()
      Constructs an IFSRandomAccessFile object.
      IFSRandomAccessFile(AS400 system, IFSFile file, java.lang.String mode, int shareOption, int existenceOption)
      Deprecated. 
      Use IFSRandomAccessFile(IFSFile,String,int,int) instead.
      IFSRandomAccessFile(AS400 system, java.lang.String name, java.lang.String mode)
      Constructs an IFSRandomAccessFile object.
      IFSRandomAccessFile(AS400 system, java.lang.String name, java.lang.String mode, int shareOption, int existenceOption)
      Constructs an IFSRandomAccessFile object.
      IFSRandomAccessFile(IFSFile file, java.lang.String mode, int shareOption, int existenceOption)
      Constructs an IFSRandomAccessFile object.
    • 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(java.beans.PropertyChangeListener listener)
      Adds a property change listener.
      void addVetoableChangeListener(java.beans.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.
      java.lang.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.
      java.lang.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.
      java.lang.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(java.beans.PropertyChangeListener listener)
      Removes a property change listener.
      void removeVetoableChangeListener(java.beans.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(java.lang.String mode)
      Sets the access mode.
      void setPath(java.lang.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(java.lang.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(java.lang.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(java.lang.String s)
      Writes out a string to the file using UTF-8 encoding in a machine-independent manner.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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,
                           java.lang.String name,
                           java.lang.String mode)
                            throws AS400SecurityException,
                                   java.io.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.
        java.io.IOException - If an error occurs while communicating with the system.
      • IFSRandomAccessFile

        public IFSRandomAccessFile(AS400 system,
                           java.lang.String name,
                           java.lang.String mode,
                           int shareOption,
                           int existenceOption)
                            throws AS400SecurityException,
                                   java.io.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.
        java.io.IOException - If an error occurs while communicating with the system.
      • IFSRandomAccessFile

        public IFSRandomAccessFile(AS400 system,
                           IFSFile file,
                           java.lang.String mode,
                           int shareOption,
                           int existenceOption)
                            throws AS400SecurityException,
                                   java.io.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.
        java.io.IOException - If an error occurs while communicating with the system.
      • IFSRandomAccessFile

        public IFSRandomAccessFile(IFSFile file,
                           java.lang.String mode,
                           int shareOption,
                           int existenceOption)
                            throws AS400SecurityException,
                                   java.io.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.
        java.io.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(java.beans.PropertyChangeListener listener)
        Adds a property change listener.
        Parameters:
        listener - The property change listener to add.
      • addVetoableChangeListener

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

        public void close()
                   throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • finalize

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

        public void flush()
                   throws java.io.IOException
        Forces any buffered output bytes to be written.
        Throws:
        java.io.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 java.io.IOException
        Returns a file descriptor associated with this stream.
        Returns:
        The file descriptor associated with this stream
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • getFilePointer

        public long getFilePointer()
                            throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • getPath

        public java.lang.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 java.io.IOException
        Returns the file length.
        Returns:
        The file length, in bytes.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • lock

        public IFSKey lock(int offset,
                  int length)
                    throws java.io.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:
        java.io.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 java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
        See Also:
        IFSKey, unlock(com.ibm.as400.access.IFSKey)
      • read

        public int read()
                 throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • read

        public int read(byte[] data)
                 throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • read

        public int read(byte[] data,
               int dataOffset,
               int length)
                 throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • readBoolean

        public final boolean readBoolean()
                                  throws java.io.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 java.io.DataInput
        Returns:
        The boolean value read.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • readByte

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

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

        public final double readDouble()
                                throws java.io.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 java.io.DataInput
        Returns:
        The next eight bytes of this file, interpreted as a double.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • readFloat

        public final float readFloat()
                              throws java.io.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 java.io.DataInput
        Returns:
        The next four bytes of this file, interpreted as a float.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • readFully

        public final void readFully(byte[] data)
                             throws java.io.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 java.io.DataInput
        Parameters:
        data - The buffer into which data is read.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • readFully

        public final void readFully(byte[] data,
                     int dataOffset,
                     int length)
                             throws java.io.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 java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • readInt

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

        public final java.lang.String readLine()
                                        throws java.io.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 java.io.DataInput
        Returns:
        The next line of text from this file.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • readLong

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

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

        public final int readUnsignedByte()
                                   throws java.io.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 java.io.DataInput
        Returns:
        The next byte of this file, interpreted as an unsigned 8-bit number.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • readUnsignedShort

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

        public final java.lang.String readUTF()
                                       throws java.io.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 java.io.DataInput
        Returns:
        A Unicode string.
        Throws:
        java.io.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(java.beans.PropertyChangeListener listener)
        Removes a property change listener.
        Parameters:
        listener - The property change listener to remove.
      • removeVetoableChangeListener

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

        public void seek(long position)
                  throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • setExistenceOption

        public void setExistenceOption(int existenceOption)
                                throws java.beans.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:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setLength

        public void setLength(int length)
                       throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • setLength

        public void setLength(long length)
                       throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • setMode

        public void setMode(java.lang.String mode)
                     throws java.beans.PropertyVetoException
        Sets the access mode.
        Parameters:
        mode - The access mode.
        • "r" read only
        • "w" write only
        • "rw" read/write
        .
        Throws:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setPath

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

        public void setShareOption(int shareOption)
                            throws java.beans.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:
        java.beans.PropertyVetoException - If the change is vetoed.
      • setSystem

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

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

        public long skipBytes(long bytesToSkip)
                       throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
      • unlock

        public void unlock(IFSKey key)
                    throws java.io.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:
        java.io.IOException - If an error occurs while communicating with the system.
        See Also:
        IFSKey, lock(int, int)
      • write

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

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

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

        public final void writeBoolean(boolean value)
                                throws java.io.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 java.io.DataOutput
        Parameters:
        value - The value to be written.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • writeByte

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

        public final void writeBytes(java.lang.String s)
                              throws java.io.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 java.io.DataOutput
        Parameters:
        s - The bytes to write.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
        See Also:
        writeChars(String)
      • writeChar

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

        public final void writeChars(java.lang.String s)
                              throws java.io.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 java.io.DataOutput
        Parameters:
        s - A String to write.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • writeDouble

        public final void writeDouble(double value)
                               throws java.io.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 java.io.DataOutput
        Parameters:
        value - The value to write.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • writeFloat

        public final void writeFloat(float value)
                              throws java.io.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 java.io.DataOutput
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • writeInt

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

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

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

        public final void writeUTF(java.lang.String s)
                            throws java.io.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 java.io.DataOutput
        Parameters:
        s - The string to write.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.