Closeable, AutoCloseable, Readablepublic class IFSFileReader extends Reader
IFSFileInputStream.
If an InputStream is required, use IFSTextFileInputStream.
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();
| Modifier and Type | Field | Description |
|---|---|---|
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 | Description |
|---|---|
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.
|
| Modifier and Type | Method | Description |
|---|---|---|
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) |
Deprecated.
Replaced by
lock(long) |
IFSKey |
lockBytes(long 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.
|
mark, nullReader, read, transferTopublic static final int SHARE_ALL
public static final int SHARE_NONE
public static final int SHARE_READERS
public static final int SHARE_WRITERS
public IFSFileReader(IFSFile file) throws AS400SecurityException, IOException
file - The file to be opened for reading.AS400SecurityException - If a security or authority error occurs.IOException - If an error occurs while communicating with the system.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 system.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 system.public IFSFileReader(IFSFileDescriptor fd) throws AS400SecurityException, IOException
fd - The file descriptor to be opened for reading.AS400SecurityException - If a security or authority error occurs.IOException - If an error occurs while communicating with the system.public void close()
throws IOException
close in interface AutoCloseableclose in interface Closeableclose in class ReaderIOException - If an error occurs while communicating with the system.public int getCCSID()
public String getEncoding()
public boolean markSupported()
markSupported in class Readerpublic int read()
throws IOException
read in class ReaderIOException - If an error occurs while communicating with the system.public int read(char[] cbuf)
throws IOException
read in class Readercbuf - Destination buffer.IOException - If an error occurs while communicating with the system.public int read(char[] cbuf,
int off,
int len)
throws IOException
read in class Readercbuf - 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 system.public boolean ready()
throws IOException
ready in class ReaderIOException - If an error occurs while communicating with the system.public void reset()
throws IOException
reset in class ReaderIOException - If an error occurs while communicating with the system.public long skip(long charsToSkip)
throws IOException
skip in class ReadercharsToSkip - The number of characters to skip.IOException - If an error occurs while communicating with the system.public IFSKey lockBytes(int length) throws IOException
lock(long)length - The number of bytes to lock.IOException - If an error occurs while communicating with the system.unlockBytes(com.ibm.as400.access.IFSKey)public IFSKey lockBytes(long length) throws IOException
length - The number of bytes to lock.IOException - If an error occurs while communicating with the system.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 system.lockBytes(long)Copyright © 2024. All rights reserved.