As we have read about the BufferedOutputStream class that store the data in an internal buffer and lets you write characters to a stream. Lets see an example that writes the text "Hello Java" to the existed file.
The given example uses the BufferedOutputstream class that writes the bytes to the output stream. The output stream is a file "Filterfile.txt" in which the data is written in form of a byte. The getBytes( ) method of the String class returns the bytes from the string.
import java.io.*;
|
Output of the Program:
| C:\nisha>javac WriteFilter.java C:\nisha>java WriteFilter the data has been written C:\nisha> |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Write to a file View All Comments
Post your Comment