Class java.io.FileOutputStream
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.io.FileOutputStream

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

public class FileOutputStream
extends OutputStream
A file output stream is an output stream for writing data to a File or to a FileDescriptor.

Version:
1.27, 07/01/98
Author:
Arthur van Hoff
Since:
JDK1.0
See Also:
File, FileDescriptor, FileInputStream

Constructor Index

 o java.io.FileOutputStream(String)
Creates an output file stream to write to the file with the specified name.
 o java.io.FileOutputStream(String, boolean)
Creates an output file with the specified system dependent file name.
 o java.io.FileOutputStream(File)
Creates a file output stream to write to the specified File object.
 o java.io.FileOutputStream(FileDescriptor)
Creates an output file stream to write to the specified file descriptor.

Method Index

 o close()
Closes this file output stream and releases any system resources associated with this stream.
 o finalize()
Ensures that the close method of this file output stream is called when there are no more references to this stream.
 o getFD()
Returns the file descriptor associated with this stream.
 o write(int)
Writes the specified byte to this file output stream.
 o write(byte[])
Writes b.length bytes from the specified byte array to this file output stream.
 o write(byte[], int, int)
Writes len bytes from the specified byte array starting at offset off to this file output stream.

Constructors

 o FileOutputStream
public FileOutputStream(String name) throws IOException
Creates an output file stream to write to the file with the specified name.

Parameters:
name - the system-dependent filename.
Throws: IOException
if the file could not be opened for writing.
Throws: SecurityException
if a security manager exists, its checkWrite method is called with the name argument to see if the application is allowed write access to the file.
Since:
JDK1.0
See Also:
checkWrite(java.lang.String)
 o FileOutputStream
public FileOutputStream(String name,
                        boolean append) 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.
Since:
JDK1.1
 o FileOutputStream
public FileOutputStream(File file) throws IOException
Creates a file output stream to write to the specified File object.

Parameters:
file - the file to be opened for writing.
Throws: IOException
if the file could not be opened for writing.
Throws: SecurityException
if a security manager exists, its checkWrite method is called with the pathname of the File argument to see if the application is allowed write access to the file. This may result in a security exception.
Since:
JDK1.0
See Also:
getPath(), SecurityException, checkWrite(java.lang.String)
 o FileOutputStream
public FileOutputStream(FileDescriptor fdObj)
Creates an output file stream to write to the specified file descriptor.

Parameters:
fdObj - the file descriptor to be opened for writing.
Throws: SecurityException
if a security manager exists, its checkWrite method is called with the file descriptor to see if the application is allowed to write to the specified file descriptor.
Since:
JDK1.0
See Also:
checkWrite(java.io.FileDescriptor)

Methods

 o close
public native void close() throws IOException
Closes this file output stream and releases any system resources associated with this stream.

Throws: IOException
if an I/O error occurs.
Overrides:
close in class OutputStream
Since:
JDK1.0
 o finalize
protected void finalize() throws IOException
Ensures that the close method of this file output stream is called when there are no more references to this stream.

Throws: IOException
if an I/O error occurs.
Overrides:
finalize in class Object
Since:
JDK1.0
See Also:
close()
 o getFD
public final java.io.FileDescriptor getFD() throws IOException
Returns the file descriptor associated with this stream.

Returns:
the file descriptor object associated with this stream.
Throws: IOException
if an I/O error occurs.
Since:
JDK1.0
See Also:
FileDescriptor
 o write
public native void write(int b) throws IOException
Writes the specified byte to this file output stream.

Parameters:
b - the byte to be written.
Throws: IOException
if an I/O error occurs.
Overrides:
write in class OutputStream
Since:
JDK1.0
 o write
public void write(byte b) throws IOException
Writes b.length bytes from the specified byte array to this file output stream.

Parameters:
b - the data.
Throws: IOException
if an I/O error occurs.
Overrides:
write in class OutputStream
Since:
JDK1.0
 o write
public void write(byte b,
                  int off,
                  int len) throws IOException
Writes len bytes from the specified byte array starting at offset off to this file output stream.

Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws: IOException
if an I/O error occurs.
Overrides:
write in class OutputStream
Since:
JDK1.0

All Packages  Class Hierarchy  This Package  Previous  Next  Index