java.io
Class FileOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.FileOutputStream

public class FileOutputStream
extends OutputStream

File output stream, can be constructed from a file descriptor or a file name.

See Also:
FileInputStream, File

Constructor Summary
FileOutputStream(File file)
          Creates an output file with the specified File object.
FileOutputStream(FileDescriptor fdObj)
           
FileOutputStream(String name)
          Creates an output file with the specified system dependent file name.
 
Method Summary
 void close()
          Closes the stream.
protected  void finalize()
          Closes the stream when garbage is collected.
 FileDescriptor getFD()
          Returns the file descriptor associated with this stream.
 void write(byte[] b)
          Writes an array of bytes.
 void write(byte[] b, int off, int len)
          Writes a sub array of bytes.
 void write(int b)
          Writes a byte of data.
 
Methods inherited from class java.io.OutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileOutputStream

public FileOutputStream(String name)
                 throws IOException
Creates an output file with the specified system dependent file name.

Parameters:
name - the system dependent file name
Throws:
IOException - If the file is not found.

FileOutputStream

public FileOutputStream(File file)
                 throws IOException
Creates an output file with the specified File object.

Parameters:
file - the file to be opened for reading
Throws:
IOException - If the file is not found.

FileOutputStream

public FileOutputStream(FileDescriptor fdObj)
Method Detail

write

public void write(int b)
           throws IOException
Writes a byte of data. This method will block until the byte is actually written.

Specified by:
write in class OutputStream
Parameters:
b - the byte to be written
Throws:
IOException - If an I/O error has occurred.

write

public void write(byte[] b)
           throws IOException
Writes an array of bytes. Will block until the bytes are actually written.

Overrides:
write in class OutputStream
Parameters:
b - the data to be written
Throws:
IOException - If an I/O error has occurred.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes a sub array of bytes.

Overrides:
write in class OutputStream
Parameters:
b - the data to be written
off - the start offset in the data
len - the number of bytes that are written
Throws:
IOException - If an I/O error has occurred.

close

public void close()
           throws IOException
Closes the stream. This method must be called to release any resources associated with the stream.

Overrides:
close in class OutputStream
Throws:
IOException - If an I/O error has occurred.

getFD

public final FileDescriptor getFD()
                           throws IOException
Returns the file descriptor associated with this stream.

Returns:
the file descriptor.
IOException

finalize

protected void finalize()
                 throws IOException
Closes the stream when garbage is collected.

Overrides:
finalize in class Object
IOException