Package java.io Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class FileOutputStream

Constructors , Methods

public  class  java.io.FileOutputStream
    extends  java.io.OutputStream  
{
        // Constructors
    public FileOutputStream(File  file);	
    public FileOutputStream(FileDescriptor  fdObj);	
    public FileOutputStream(String  name);	

        // Methods
    public void close();	
    protected void finalize();	
    public final FileDescriptor getFD();	
    public void write(byte  b[]);	
    public void write(byte  b[], int  off, int  len);	
    public void write(int  b);	
}

A file output stream is an output stream for writing data to a File or to a FileDescriptor .


Constructors


FileOutputStream

public FileOutputStream(File  file) 
throws IOException 

Creates an file output stream to write to the specified File object

ParameterDescription
file the file to be opened for writing

Throw:

IOException

If the file could not be opened for writing.

Throw:

SecurityException

If a security manager exists, its checkWrite method is called with the path name of the File argument to see if the application is allowed write access to the file. This may result in a security exception .


FileOutputStream

public FileOutputStream(FileDescriptor  fdObj) 

Creates an output file stream to write to the specified file descriptor

ParameterDescription
fdObj the file descriptor to be opened for writing

Throw:

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. This may result in a security exception .


FileOutputStream

public FileOutputStream(String  name) 
throws IOException 

Creates an output file stream to write to the file with the specified name.

ParameterDescription
name the system dependent file name

Throw:

IOException

If the file could not be opened for writing.

Throw:

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. This may result in a security exception .


Methods


close

public void close() 
throws IOException 

Closes this file output stream and releases any system resources associated with this stream.

Throw:

IOException

If an I/O error occurs.

Overrides:

close in class OutputStream .


finalize

protected void finalize() 
throws IOException 

This finalize method ensures that the close method of this file output stream is called when there are no more references to this stream.

Throw:

IOException

If an I/O error occurs.

Overrides:

finalize in class Object .


getFD

public final FileDescriptor getFD() 
throws IOException 

Return Value:

Returns the file descriptor object associated with this stream.

Throw:

IOException

If an I/O error occurs.


write

public void write(byte  b[]) 
throws IOException 

Writes b.length bytes from the specified byte array to this file output stream.

ParameterDescription
b the data

Throw:

IOException

If an I/O error occurs.

Overrides:

write in class OutputStream .


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.

ParameterDescription
b the data
off the start offset in the data
len the number of bytes to write

Throw:

IOException

If an I/O error occurs.

Overrides:

write in class OutputStream .


write

public void write(int  b) 
throws IOException 

Writes the specified byte to this file output stream.

ParameterDescription
b the byte to be written

Throw:

IOException

If an I/O error occurs.

Overrides:

write in class OutputStream .



Top© 1996 Sun Microsystems, Inc. All rights reserved.