All Packages Class Hierarchy This Package Previous Next Index
Class java.io.FileOutputStream
java.lang.Object
|
+----java.io.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
.
- Since:
- JDK1.0
- See Also:
- File, FileDescriptor, FileInputStream
-
FileOutputStream(File)
- Creates a file output stream to write to the specified
File
object.
-
FileOutputStream(FileDescriptor)
- Creates an output file stream to write to the specified file descriptor.
-
FileOutputStream(String)
- Creates an output file stream to write to the file with the
specified name.
-
FileOutputStream(String, boolean)
- Creates an output file with the specified system dependent
file name.
-
close()
- Closes this file output stream and releases any system resources
associated with this stream.
-
finalize()
- Ensures that the
close
method of this file output stream is
called when there are no more references to this stream.
-
getFD()
- Returns the file descriptor associated with this stream.
-
write(byte[])
- Writes
b.length
bytes from the specified byte array
to this file output stream.
-
write(byte[], int, int)
- Writes
len
bytes from the specified byte array
starting at offset off
to this file output stream.
-
write(int)
- Writes the specified byte to this file output stream.
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.
- See Also:
- checkWrite
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.
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.
- See Also:
- getPath, SecurityException, checkWrite
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.
- See Also:
- checkWrite
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
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
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
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
getFD
public final 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.
- See Also:
- FileDescriptor
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
- See Also:
- close
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature