|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.Writer | +--com.ibm.as400.access.IFSFileWriter
Convenience class for writing character files in the integrated file system.
The behavior of this class is comparable to java.io.FileWriter.
IFSFileWriter is meant for writing streams of characters.
For writing streams of raw bytes, consider using a IFSFileOutputStream
.
The following example illustrates the use of IFSFileWriter:
import java.io.PrintWriter; import java.io.BufferedWriter; // Work with /File1 on the system eniac. AS400 as400 = new AS400("eniac"); IFSFile file = new IFSFile(system, "/File1"); PrintWriter writer = new PrintWriter(new BufferedWriter(new IFSFileWriter(file))); // Write a line of text to the file, converting characters. writer.println(text); // Close the file. writer.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.Writer |
lock |
Constructor Summary | |
IFSFileWriter(IFSFile file)
Constructs an IFSFileWriter object. |
|
IFSFileWriter(IFSFile file,
boolean append)
Constructs an IFSFileWriter object. |
|
IFSFileWriter(IFSFile file,
boolean append,
int shareOption)
Constructs an IFSFileWriter object. |
|
IFSFileWriter(IFSFile file,
boolean append,
int shareOption,
int ccsid)
Constructs an IFSFileWriter object. |
|
IFSFileWriter(IFSFileDescriptor fd)
Constructs an IFSFileWriter object. |
|
IFSFileWriter(IFSFile file,
int ccsid)
Constructs an IFSFileWriter object. |
Method Summary | |
Writer |
append(char c)
Appends the specified character to this writer. |
Writer |
append(CharSequence csq)
Appends the specified character sequence to this writer. |
Writer |
append(CharSequence csq,
int start,
int end)
Appends a subsequence of the specified character sequence to this writer. |
void |
close()
Closes the stream, flushing it first. |
void |
flush()
Flushes the underlying output stream. |
int |
getCCSID()
Returns the CCSID used by this IFSFileWriter. |
String |
getEncoding()
Returns the encoding used by this IFSFileWriter. |
IFSKey |
lockBytes(int length)
Places a lock on the file at the current position for the specified number of bytes. |
void |
unlockBytes(IFSKey key)
Undoes a lock on the file. |
void |
write(char[] buffer)
Writes the specified array of characters. |
void |
write(char[] buffer,
int offset,
int length)
Writes a portion of an array of characters. |
void |
write(int c)
Writes a single character. |
void |
write(String data)
Writes a String. |
void |
write(String data,
int offset,
int length)
Writes a portion of a String. |
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 IFSFileWriter(IFSFile file) throws AS400SecurityException, IOException
file
- The file to be opened for writing.
AS400SecurityException
- If a security or authority error occurs.
IOException
- If an error occurs while communicating with the server.public IFSFileWriter(IFSFile file, int ccsid) throws AS400SecurityException, IOException
file
- The file to be opened for writing.ccsid
- The CCSID to convert the data to when writing to the file.
The file's "data CCSID" tag on the server is not changed.
AS400SecurityException
- If a security or authority error occurs.
IOException
- If an error occurs while communicating with the server.public IFSFileWriter(IFSFile file, boolean append) throws AS400SecurityException, IOException
file
- The file to be opened for writing.append
- If true, output is appended to the file; otherwise, any data currently in the file will be overwritten.
AS400SecurityException
- If a security or authority error occurs.
IOException
- If an error occurs while communicating with the server.public IFSFileWriter(IFSFile file, boolean append, int shareOption) throws AS400SecurityException, IOException
file
- The file to be opened for writing.append
- If true, output is appended to the file; otherwise, any data currently in the file will be overwritten.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 IFSFileWriter(IFSFile file, boolean append, int shareOption, int ccsid) throws AS400SecurityException, IOException
file
- The file to be opened for writing.append
- If true, output is appended to the file; otherwise, any data currently in the file will be overwritten.shareOption
- Indicates how users can access the file. ccsid
- The CCSID to convert the data to when writing to the file.
The file's "data CCSID" tag on the server is not changed.
AS400SecurityException
- If a security or authority error occurs.
IOException
- If an error occurs while communicating with the server.public IFSFileWriter(IFSFileDescriptor fd) throws AS400SecurityException, IOException
fd
- The file descriptor to be opened for writing.Method Detail |
public Writer append(char c) throws IOException
c
- - The 16-bit character to append.
IOException
- If an I/O error occurspublic Writer append(CharSequence csq) throws IOException
csq
- The character sequence to append. If csq is null, then the four characters "null" are appended to this writer.
IOException
- If an I/O error occurspublic Writer append(CharSequence csq, int start, int end) throws IOException
csq
- The character
sequence from which a subsequence will be appended. If csq is null,
then characters will be appended as if csq contained the four
characters "null".start
- The index of the first character in the subsequenceend
- The index of the character following the last character in the subsequence
IndexOutOfBoundsException
- If start or end are negative, start is greater than end, or end is greater than csq.length()
IOException
- If an I/O error occurspublic void close() throws IOException
close
in class Writer
IOException
- If an error occurs while communicating with the server.public void flush() throws IOException
flush
in class Writer
IOException
- If an error occurs while communicating with the server.public int getCCSID()
public String getEncoding()
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)
public void write(int c) throws IOException
write
in class Writer
c
- int specifying a character to be written.
IOException
- If an error occurs while communicating with the server.public void write(char[] buffer) throws IOException
write
in class Writer
buffer
- The characters to be written.
IOException
- If an error occurs while communicating with the server.public void write(char[] buffer, int offset, int length) throws IOException
write
in class Writer
buffer
- The characters to be written.offset
- The offset into the array from which to begin extracting characters to write.length
- The number of characters to write.
IOException
- If an error occurs while communicating with the server.public void write(String data) throws IOException
write
in class Writer
data
- The String to write.
IOException
- If an error occurs while communicating with the server.public void write(String data, int offset, int length) throws IOException
write
in class Writer
data
- The String to write.offset
- The offset into the String from which to begin extracting characters to write.length
- The number of characters to write.
IOException
- If an error occurs while communicating with the server.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |