Package java.io |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
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 .
public FileOutputStream(File file)throws IOExceptionCreates an file output stream to write to the specified File object
Parameter Description file the file to be opened for writing Throw:
If the file could not be opened for writing.
Throw:
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 .
public FileOutputStream(FileDescriptor fdObj)Creates an output file stream to write to the specified file descriptor
Parameter Description fdObj the file descriptor to be opened for writing Throw:
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 .
public FileOutputStream(String name)throws IOExceptionCreates an output file stream to write to the file with the specified name.
Parameter Description name the system dependent file name Throw:
If the file could not be opened for writing.
Throw:
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 .
public void close()throws IOExceptionCloses this file output stream and releases any system resources associated with this stream.
Throw:
If an I/O error occurs.
Overrides:
close in class OutputStream .
protected void finalize()throws IOExceptionThis finalize method ensures that the close method of this file output stream is called when there are no more references to this stream.
Throw:
If an I/O error occurs.
Overrides:
finalize in class Object .
public final FileDescriptor getFD()throws IOExceptionReturn Value:
Returns the file descriptor object associated with this stream.
Throw:
If an I/O error occurs.
public void write(byte b[])throws IOExceptionWrites b.length bytes from the specified byte array to this file output stream.
Parameter Description b the data Throw:
If an I/O error occurs.
Overrides:
write in class OutputStream .
public void write(byte b[], int off, int len)throws IOExceptionWrites len bytes from the specified byte array starting at offset off to this file output stream.
Parameter Description b the data off the start offset in the data len the number of bytes to write Throw:
If an I/O error occurs.
Overrides:
write in class OutputStream .
public void write(int b)throws IOExceptionWrites the specified byte to this file output stream.
Parameter Description b the byte to be written Throw:
If an I/O error occurs.
Overrides:
write in class OutputStream .