|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.Reader | +--com.ibm.as400.access.IFSFileReader
Convenience class for reading character files in the integrated file system.
The behavior of this class is comparable to java.io.FileReader.
IFSFileReader is meant for reading streams of characters.
For reading streams of raw bytes, consider using a IFSFileInputStream
.
The following example illustrates the use of IFSFileReader:
import java.io.BufferedReader; // Work with /File1 on the system eniac. AS400 system = new AS400("eniac"); IFSFile file = new IFSFile(system, "/File1"); BufferedReader reader = new BufferedReader(new IFSFileReader(file)); // Read the first line of the file, converting characters. String line1 = reader.readLine(); // Display the String that was read. System.out.println(line1); // Close the reader. reader.close();
Field Summary | |
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. |
Fields inherited from class java.io.Reader |
lock |
Constructor Summary | |
IFSFileReader(IFSFile file)
Constructs an IFSFileReader object. |
|
IFSFileReader(IFSFileDescriptor fd)
Constructs an IFSFileReader object. |
|
IFSFileReader(IFSFile file,
int ccsid)
Constructs an IFSFileReader object. |
|
IFSFileReader(IFSFile file,
int ccsid,
int shareOption)
Constructs an IFSFileReader object. |
Method Summary | |
void |
close()
Closes the stream. |
int |
getCCSID()
Returns the CCSID used by this IFSFileReader. |
String |
getEncoding()
Returns the encoding used by this IFSFileReader. |
IFSKey |
lockBytes(int length)
Places a lock on the file at the current position for the specified number of bytes. |
boolean |
markSupported()
IFSFileReader does not support the mark() operation. |
int |
read()
Reads a single character. |
int |
read(char[] cbuf)
Reads characters into an array. |
int |
read(char[] cbuf,
int off,
int len)
Reads characters into a portion of an array. |
boolean |
ready()
Tells whether this stream is ready to be read. |
void |
reset()
Resets the stream. |
long |
skip(long charsToSkip)
Skip characters. |
void |
unlockBytes(IFSKey key)
Undoes a lock on the file. |
Methods inherited from class java.io.Reader |
mark |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SHARE_ALL
public static final int SHARE_NONE
public static final int SHARE_READERS
public static final int SHARE_WRITERS
Constructor Detail |
public IFSFileReader(IFSFile file) throws AS400SecurityException, IOException
file
- The file to be opened for reading.
public IFSFileReader(IFSFile file, int ccsid) throws AS400SecurityException, IOException
file
- The file to be opened for reading.ccsid
- The CCSID that the file data is currently in.
AS400SecurityException
- If a security or authority error occurs.
IOException
- If an error occurs while communicating with the server.public IFSFileReader(IFSFile file, int ccsid, int shareOption) throws AS400SecurityException, IOException
file
- The file to be opened for reading.ccsid
- The CCSID that the file data is currently in.shareOption
- Indicates how users can access the file. AS400SecurityException
- If a security or authority error occurs.
IOException
- If an error occurs while communicating with the server.public IFSFileReader(IFSFileDescriptor fd) throws AS400SecurityException, IOException
fd
- The file descriptor to be opened for reading.Method Detail |
public void close() throws IOException
close
in class Reader
IOException
- If an error occurs while communicating with the server.public int getCCSID()
public String getEncoding()
public boolean markSupported()
markSupported
in class Reader
public int read() throws IOException
read
in class Reader
IOException
- If an error occurs while communicating with the server.public int read(char[] cbuf) throws IOException
read
in class Reader
cbuf
- Destination buffer.
IOException
- If an error occurs while communicating with the server.public int read(char[] cbuf, int off, int len) throws IOException
read
in class Reader
cbuf
- Destination buffer.off
- Offset at which to start storing characters.len
- Maximum number of characters to read.
IOException
- If an error occurs while communicating with the server.public boolean ready() throws IOException
ready
in class Reader
IOException
- If an error occurs while communicating with the server.public void reset() throws IOException
reset
in class Reader
IOException
- If an error occurs while communicating with the server.public long skip(long charsToSkip) throws IOException
skip
in class Reader
charsToSkip
- The number of characters to skip.
IOException
- If an error occurs while communicating with the server.public IFSKey lockBytes(int length) throws IOException
length
- The number of bytes to lock.
IOException
- If an error occurs while communicating with the server.unlockBytes(com.ibm.as400.access.IFSKey)
public void unlockBytes(IFSKey key) throws IOException
key
- The key for the lock.
IOException
- If an error occurs while communicating with the server.lockBytes(int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |