Using OutputStreamWriter:
using OutputStreamWriter !!
using OutputStreamWriter !!
using OutputStreamWriter !!
using OutputStreamWriter !!
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.OutputStreamWriter;
- public class WriteByOutputStreamWriterExe {
- public static void main(String[] args) throws Exception {
- File file = new File("D:\\data1.txt");
- FileOutputStream fileStream = new FileOutputStream(file);
- OutputStreamWriter outputStream = new OutputStreamWriter(fileStream);
- for (int i = 0; i < 5; i++) {
- outputStream.write("using OutputStreamWriter !!");
- outputStream.append("\n");
- }
- outputStream.close();
- }
- }
Output:
using OutputStreamWriter !!using OutputStreamWriter !!
using OutputStreamWriter !!
using OutputStreamWriter !!
using OutputStreamWriter !!
No comments:
Post a Comment