All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.IFSFileOutputStream

java.lang.Object
   |
   +----java.io.OutputStream
           |
           +----com.ibm.as400.access.IFSFileOutputStream

public class IFSFileOutputStream
extends OutputStream
implements Serializable
The IFSFileOutputStream class represents an integrated file system file output stream. An integrated file system file output stream is an output stream for writing data to integrated file system objects.
IFSFileOutputStream objects are capable of generating file events that call the following FileListener methods: fileClosed, fileModified, and fileOpended.
The following example illustrates the use of IFSFileOutputStream:
// Work with /Dir/File on the system eniac.
AS400 as400 = new AS400("eniac");
IFSFileOutputStream file = new IFSFileOutputStream(as400, "/Dir/File");
// Lock the first 8 bytes of the file. IFSKey key = file.lock(8);
// Write 8 bytes to the file. byte[] data = { 0, 1, 2, 3, 4, 5, 6, 7 }; file.write(data, 0, 8);
// Unlock the first 8 bytes. file.unlock(key);
// Close the file. file.close();

See Also:
FileEvent, addFileListener, removeFileListener

Variable Index

 o changes_
 o fd_
 o SHARE_ALL
Share option that allows read and write access by other users.
 o SHARE_NONE
Share option that does not allow read or write access by other users.
 o SHARE_READERS
Share option that allows only read access by other users.
 o SHARE_WRITERS
Share option that allows only write access by other users.
 o vetos_

Constructor Index

 o IFSFileOutputStream()
Constructs an IFSFileOutputStream object.
 o IFSFileOutputStream(AS400, IFSFile, int, boolean)
Constructs an IFSFileOutputStream object.
 o IFSFileOutputStream(AS400, String)
Constructs an IFSFileOutputStream object.
 o IFSFileOutputStream(AS400, String, int, boolean)
Constructs an IFSFileOutputStream object.
 o IFSFileOutputStream(IFSFileDescriptor)
Creates a file output stream to write to file descriptor fd.

Method Index

 o addFileListener(FileListener)
Adds a file listener to receive file events from this IFSFileOutputStream.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a property change listener.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a vetoable change listener.
 o close()
Closes this file output stream and releases any system resources associated with this stream.
 o connectionDropped(ConnectionDroppedException)
Disconnects from the byte stream server.
 o finalize()
Ensures that the file output stream is closed when there are no more references to it.
 o flush()
Forces any buffered output bytes to be written.
 o getFD()
Returns the file descriptor associated with this stream.
 o getPath()
Returns the integrated file system path name of the object represented by this IFSFileOutputStream object.
 o getShareOption()
Returns the share option for this object.
 o getSystem()
Returns the AS400 system object for this stream.
 o lock(int)
Places a lock on the file at the current position for the specified number of bytes.
 o open(int)
Opens the specified file.
 o removeFileListener(FileListener)
Removes a file listener so that it no longer receives file events from this IFSFileOutputStream.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a property change listener.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a vetoable change listener.
 o setAppend(boolean)
Sets the append option.
 o setFD(IFSFileDescriptor)
Sets the file descriptor.
 o setPath(String)
Sets the integrated file system path name.
 o setShareOption(int)
Sets the share option.
 o setSystem(AS400)
Sets the system.
 o unlock(IFSKey)
Undoes a lock on this file.
 o write(byte[])
Writes data.length bytes of data from the byte array data to this file output stream.
 o write(byte[], int, int)
Writes length bytes of data from the byte array data, starting at offset, to this file output stream.
 o write(int)
Writes the specified byte to this file output stream.

Variables

 o SHARE_ALL
 public static final int SHARE_ALL
Share option that allows read and write access by other users.

 o SHARE_NONE
 public static final int SHARE_NONE
Share option that does not allow read or write access by other users.

 o SHARE_READERS
 public static final int SHARE_READERS
Share option that allows only read access by other users.

 o SHARE_WRITERS
 public static final int SHARE_WRITERS
Share option that allows only write access by other users.

 o changes_
 protected transient PropertyChangeSupport changes_
 o vetos_
 protected transient VetoableChangeSupport vetos_
 o fd_
 protected IFSFileDescriptor fd_

Constructors

 o IFSFileOutputStream
 public IFSFileOutputStream()
Constructs an IFSFileOutputStream object. It is a default file output stream.

 o IFSFileOutputStream
 public IFSFileOutputStream(AS400 system,
                            String name) throws AS400SecurityException, IOException
Constructs an IFSFileOutputStream object. It creates a file output stream to write to the file with the specified name. Other readers and writers are allowed to access the file. The file is replaced if it exists; otherwise, the file is created.

Parameters:
system - The AS/400 that contains the file.
name - The file to be opened for writing.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o IFSFileOutputStream
 public IFSFileOutputStream(AS400 system,
                            String name,
                            int shareOption,
                            boolean append) throws AS400SecurityException, IOException
Constructs an IFSFileOutputStream object. It creates a file output stream to write to the file with the specified name.

Parameters:
system - The AS/400 that contains the file.
name - The file to be opened for writing.
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
append - Controls the behavior of the file. If true, output is appended to the file; otherwise, the output replaces the file contents.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o IFSFileOutputStream
 public IFSFileOutputStream(AS400 system,
                            IFSFile file,
                            int shareOption,
                            boolean append) throws AS400SecurityException, IOException
Constructs an IFSFileOutputStream object. It creates a file output stream to write to the file specified by file.

Parameters:
system - The AS/400 that contains the file.
file - The file to be opened for writing.
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
append - Controls the behavior of the file. If true, output is appended to the file; otherwise, the output replaces the file contents.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o IFSFileOutputStream
 public IFSFileOutputStream(IFSFileDescriptor fd)
Creates a file output stream to write to file descriptor fd.

Parameters:
fd - The file descriptor to be opened for writing.

Methods

 o addFileListener
 public synchronized void addFileListener(FileListener listener)
Adds a file listener to receive file events from this IFSFileOutputStream.

Parameters:
listener - The file listener.
 o addPropertyChangeListener
 public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change listener.

Parameters:
listener - The property change listener to add.
 o addVetoableChangeListener
 public synchronized void addVetoableChangeListener(VetoableChangeListener listener)
Adds a vetoable change listener.

Parameters:
listener - The vetoable change listener to add.
 o close
 public void close() throws IOException
Closes this file output stream and releases any system resources associated with this stream.

Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Overrides:
close in class OutputStream
 o connectionDropped
 protected void connectionDropped(ConnectionDroppedException e) throws ConnectionDroppedException
Disconnects from the byte stream server.

Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
 o finalize
 protected void finalize() throws IOException
Ensures that the file output stream is closed when there are no more references to it.

Throws: IOException
If an error occurs while communicating with the AS/400.
Overrides:
finalize in class Object
 o flush
 public void flush() throws IOException
Forces any buffered output bytes to be written.

Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Overrides:
flush in class OutputStream
 o getFD
 public final IFSFileDescriptor getFD() throws IOException
Returns the file descriptor associated with this stream.

Returns:
The file descriptor associated with this stream.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
 o getPath
 public String getPath()
Returns the integrated file system path name of the object represented by this IFSFileOutputStream object.

Returns:
The absolute path name of the object.
 o getShareOption
 public int getShareOption()
Returns the share option for this object.

Returns:
The share option.
 o getSystem
 public AS400 getSystem()
Returns the AS400 system object for this stream.

Returns:
The AS400 system object.
 o lock
 public IFSKey lock(int length) throws IOException
Places a lock on the file at the current position for the specified number of bytes.

Parameters:
length - The number of bytes to lock.
Returns:
A key for undoing this lock.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
See Also:
IFSKey, unlock
 o open
 protected void open(int fileDataCCSID) throws IOException
Opens the specified file.

 o removeFileListener
 public synchronized void removeFileListener(FileListener listener)
Removes a file listener so that it no longer receives file events from this IFSFileOutputStream.

Parameters:
listener - The file listener.
 o removePropertyChangeListener
 public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener.

Parameters:
listener - The property change listener to remove.
 o removeVetoableChangeListener
 public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a vetoable change listener.

Parameters:
listener - The vetoable change listener to remove.
 o setAppend
 public void setAppend(boolean append) throws PropertyVetoException
Sets the append option.

Parameters:
append - If true, data is appended to an existing file; otherwise, output replaces any existing file data.
Throws: PropertyVetoException
If the change is vetoed.
 o setFD
 public void setFD(IFSFileDescriptor fd) throws PropertyVetoException
Sets the file descriptor.

Parameters:
fd - The file descriptor.
Throws: PropertyVetoException
If the change is vetoed.
 o setPath
 public void setPath(String path) throws PropertyVetoException
Sets the integrated file system path name.

Parameters:
path - The absolute integrated file system path name.
Throws: PropertyVetoException
If the change is vetoed.
 o setShareOption
 public void setShareOption(int shareOption) throws PropertyVetoException
Sets the share option.

Parameters:
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: PropertyVetoException
If the change is vetoed.
 o setSystem
 public void setSystem(AS400 system) throws PropertyVetoException
Sets the system.

Parameters:
system - The AS/400 system object.
Throws: PropertyVetoException
If the change is vetoed.
 o unlock
 public void unlock(IFSKey key) throws IOException
Undoes a lock on this file.

Parameters:
key - The key for the lock.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
See Also:
IFSKey, lock
 o write
 public void write(int b) throws IOException
Writes the specified byte to this file output stream.

Parameters:
b - The byte to be written.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Overrides:
write in class OutputStream
 o write
 public void write(byte data[]) throws IOException
Writes data.length bytes of data from the byte array data to this file output stream.

Parameters:
data - The data to be written.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Overrides:
write in class OutputStream
 o write
 public void write(byte data[],
                   int dataOffset,
                   int length) throws IOException
Writes length bytes of data from the byte array data, starting at offset, to this file output stream.

Parameters:
data - The data to be written.
offset - The start offset in the data.
length - The number of bytes to write.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: InterruptedIOException
If this thread is interrupted.
Throws: ExtendedIOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Overrides:
write in class OutputStream

All Packages  Class Hierarchy  This Package  Previous  Next  Index