public class IFSFileWriter
extends java.io.Writer
IFSFileOutputStream.
If an OutputStream is required, use IFSTextFileOutputStream.
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();
| Modifier and Type | Field and Description | 
|---|---|
| static int | SHARE_ALLShare option that allows read and write access by other users. | 
| static int | SHARE_NONEShare option that does not allow read or write access by other users. | 
| static int | SHARE_READERSShare option that allows only read access by other users. | 
| static int | SHARE_WRITERSShare option that allows only write access by other users. | 
| Constructor and Description | 
|---|
| 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. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Closes the stream, flushing it first. | 
| void | flush()Flushes the underlying output stream. | 
| int | getCCSID()Returns the CCSID used by this IFSFileWriter. | 
| java.lang.String | getEncoding()Returns the encoding used by this IFSFileWriter. | 
| 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. | 
| 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(java.lang.String data)Writes a String. | 
| void | write(java.lang.String data,
     int offset,
     int length)Writes a portion of a String. | 
public static final int SHARE_ALL
public static final int SHARE_NONE
public static final int SHARE_READERS
public static final int SHARE_WRITERS
public IFSFileWriter(IFSFile file) throws AS400SecurityException, java.io.IOException
file - The file to be opened for writing.AS400SecurityException - If a security or authority error occurs.java.io.IOException - If an error occurs while communicating with the system.IFSFile.createNewFile()public IFSFileWriter(IFSFile file, int ccsid) throws AS400SecurityException, java.io.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 system is not changed.AS400SecurityException - If a security or authority error occurs.java.io.IOException - If an error occurs while communicating with the system.IFSFile.createNewFile()public IFSFileWriter(IFSFile file, boolean append) throws AS400SecurityException, java.io.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.java.io.IOException - If an error occurs while communicating with the system.IFSFile.createNewFile()public IFSFileWriter(IFSFile file, boolean append, int shareOption) throws AS400SecurityException, java.io.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.java.io.IOException - If an error occurs while communicating with the system.IFSFile.createNewFile()public IFSFileWriter(IFSFile file, boolean append, int shareOption, int ccsid) throws AS400SecurityException, java.io.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 system is not changed.AS400SecurityException - If a security or authority error occurs.java.io.IOException - If an error occurs while communicating with the system.IFSFile.createNewFile()public IFSFileWriter(IFSFileDescriptor fd) throws AS400SecurityException, java.io.IOException
fd - The file descriptor to be opened for writing.AS400SecurityException - If a security or authority error occurs.java.io.IOException - If an error occurs while communicating with the system.IFSFile.createNewFile()public void close()
           throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.Writerjava.io.IOException - If an error occurs while communicating with the system.public void flush()
           throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.Writerjava.io.IOException - If an error occurs while communicating with the system.public int getCCSID()
public java.lang.String getEncoding()
public IFSKey lockBytes(int length) throws java.io.IOException
lock(long)length - The number of bytes to lock.java.io.IOException - If an error occurs while communicating with the system.unlockBytes(com.ibm.as400.access.IFSKey)public IFSKey lockBytes(long length) throws java.io.IOException
length - The number of bytes to lock.java.io.IOException - If an error occurs while communicating with the system.unlockBytes(com.ibm.as400.access.IFSKey)public void unlockBytes(IFSKey key) throws java.io.IOException
key - The key for the lock.java.io.IOException - If an error occurs while communicating with the system.lockBytes(long)public void write(int c)
           throws java.io.IOException
write in class java.io.Writerc - int specifying a character to be written.java.io.IOException - If an error occurs while communicating with the system.public void write(char[] buffer)
           throws java.io.IOException
write in class java.io.Writerbuffer - The characters to be written.java.io.IOException - If an error occurs while communicating with the system.public void write(char[] buffer,
         int offset,
         int length)
           throws java.io.IOException
write in class java.io.Writerbuffer - 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.java.io.IOException - If an error occurs while communicating with the system.public void write(java.lang.String data)
           throws java.io.IOException
write in class java.io.Writerdata - The String to write.java.io.IOException - If an error occurs while communicating with the system.public void write(java.lang.String data,
         int offset,
         int length)
           throws java.io.IOException
write in class java.io.Writerdata - 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.java.io.IOException - If an error occurs while communicating with the system.