Java I/O StreamsLesson 56Free preview
Java FileOutputStream
This lesson is part of Java · All levels
Summary
FileOutputStream writes bytes to a file, with the option of either adding to the old content or adding to the end via the append parameter. Suitable for storing binary data such as images, audio, or the results of object serialization. The data that is still stored in the new buffer is actually written after flush() or close() is called.
Key points
- Constructors add content, and the new
- Write(int b) wrote one byte, write(byte[]) and write(byte[], off, len) wrote many
- If the file doesn't exist, the stream will automate it.
- Data can be lost if you forget because the buffer has not been sent to the disk
- It can be packed into BufferedOutputStream to write a lot of small data quickly
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.