com.ibm.as400.access

Class IFSTextFileInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Serializable


    public class IFSTextFileInputStream
    extends IFSFileInputStream
    implements java.io.Serializable
    Represents an integrated file system input stream for character data.
    IFSTextFileInputStream objects are capable of generating file events which call the following FileListener methods: fileClosed and fileOpened.
    Note: This class is provided for situations where an InputStream is required. The preferred method of reading a text file is via IFSFileReader.

    The following example illustrates the use of IFSTextFileInputStream:

    // Work with /File on the system eniac.
    AS400 as400 = new AS400("eniac");
    IFSTextFileInputStream file = new IFSTextFileInputStream(as400, "/File");
    // Read the first four characters of the file. String s = file.read(4); // Display the characters read. System.out.println(s); // Close the file. file.close();
    See Also:
    FileEvent, IFSFileInputStream.addFileListener(com.ibm.as400.access.FileListener), IFSFileInputStream.removeFileListener(com.ibm.as400.access.FileListener), Serialized Form
    • Constructor Detail

      • IFSTextFileInputStream

        public IFSTextFileInputStream()
        Constructs an IFSTextFileInputStream object.
      • IFSTextFileInputStream

        public IFSTextFileInputStream(AS400 system,
                              java.lang.String name)
                               throws AS400SecurityException,
                                      java.io.IOException
        Constructs an IFSTextFileInputStream object. It creates a file input stream to read from the text file name. Other readers and writers are allowed to access the file. The file is opened if it exists; otherwise an exception is thrown.
        Parameters:
        system - The AS400 that contains the file.
        name - The integrated file system name.
        Throws:
        AS400SecurityException - If a security or authority error occurs.
        java.io.IOException - If an error occurs while communicating with the system.
      • IFSTextFileInputStream

        public IFSTextFileInputStream(AS400 system,
                              java.lang.String name,
                              int shareOption)
                               throws AS400SecurityException,
                                      java.io.IOException
        Constructs an IFSTextFileInputStream object. It creates a file input stream to read from the text file name.
        Parameters:
        system - The AS400 that contains the file.
        name - The integrated file system name.
        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:
        AS400SecurityException - If a security or authority error occurs.
        java.io.IOException - If an error occurs while communicating with the system.
      • IFSTextFileInputStream

        public IFSTextFileInputStream(IFSFile file)
                               throws AS400SecurityException,
                                      java.io.IOException
        Constructs an IFSTextFileInputStream object. It creates a file input stream to read from the text file specified by file. Other readers and writers are allowed to access the file. The file is opened if it exists; otherwise an exception is thrown.
        Parameters:
        file - The file to be opened for reading.
        Throws:
        AS400SecurityException - If a security or authority error occurs.
        java.io.IOException - If an error occurs while communicating with the system.
      • IFSTextFileInputStream

        public IFSTextFileInputStream(AS400 system,
                              IFSFile file,
                              int shareOption)
                               throws AS400SecurityException,
                                      java.io.IOException
        Constructs an IFSTextFileInputStream object. It creates a file input stream to read from the text file specified by file.
        Parameters:
        system - The AS400 that contains the file.
        file - The file to be opened for reading.
        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:
        AS400SecurityException - If a security or authority error occurs.
        java.io.IOException - If an error occurs while communicating with the system.
      • IFSTextFileInputStream

        public IFSTextFileInputStream(IFSJavaFile file)
                               throws AS400SecurityException,
                                      java.io.IOException
        Constructs an IFSTextFileInputStream object. It creates a file input stream to read from the text file specified by file. Other readers and writers are allowed to access the file. The file is opened if it exists; otherwise an exception is thrown.
        Parameters:
        file - The file to be opened for reading.
        Throws:
        AS400SecurityException - If a security or authority error occurs.
        java.io.IOException - If an error occurs while communicating with the system.
      • IFSTextFileInputStream

        public IFSTextFileInputStream(AS400 system,
                              IFSJavaFile file,
                              int shareOption)
                               throws AS400SecurityException,
                                      java.io.IOException
        Constructs an IFSTextFileInputStream object. It creates a file input stream to read from the text file specified by file.
        Parameters:
        system - The AS400 that contains the file.
        file - The file to be opened for reading.
        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:
        AS400SecurityException - If a security or authority error occurs.
        java.io.IOException - If an error occurs while communicating with the system.
      • IFSTextFileInputStream

        public IFSTextFileInputStream(IFSFileDescriptor fd)
        Constructs an IFSTextFileInputStream object. It creates a text file input stream to read from file descriptor fd.
        Parameters:
        fd - The file descriptor to be opened for reading.
    >
    • Method Detail

      • read

        public java.lang.String read(int length)
                              throws java.io.IOException
        Reads up to length characters from this text file input stream. The file contents are converted from the file data CCSID to Unicode if the encoding is supported.
        Parameters:
        length - The number of characters to read from the stream.
        Returns:
        The characters read from the stream. If the end of file has been reached an empty String is returned.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.