Module java.base
Package java.io

Class FileOutputStream

java.lang.Object
java.io.OutputStream
java.io.FileOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class FileOutputStream extends OutputStream
A file output stream is an output stream for writing data to a File or to a FileDescriptor. Whether or not a file is available or may be created depends upon the underlying platform. Some platforms, in particular, allow a file to be opened for writing by only one FileOutputStream (or other file-writing object) at a time. In such situations the constructors in this class will fail if the file involved is already open.

FileOutputStream is meant for writing streams of raw bytes such as image data. For writing streams of characters, consider using FileWriter.

API Note:
The close() method should be called to release resources used by this stream, either directly, or with the try-with-resources statement.
Implementation Requirements:
Subclasses are responsible for the cleanup of resources acquired by the subclass. Subclasses requiring that resource cleanup take place after a stream becomes unreachable should use Cleaner or some other mechanism.
Since:
1.0
See Also: