-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBufferedOutputStreamExample.java
More file actions
33 lines (25 loc) · 805 Bytes
/
BufferedOutputStreamExample.java
File metadata and controls
33 lines (25 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package io;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.util.Scanner;
public class BufferedOutputStreamExample {
public static void main(String[] args) {
try {
FileOutputStream fout = new FileOutputStream("D:\\bstud.txt");
BufferedOutputStream bout = new BufferedOutputStream(fout);
System.out.println("Type Text:");
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
// String str = "Java developers of Nepal.\nRunning Chapter: File
// Handling, BufferedOutputStream";
byte[] b = str.getBytes();
bout.write(b);
bout.flush();
bout.close();
fout.close();
System.out.println("Information is added in the file.");
} catch (Exception e) {
e.printStackTrace();
}
}
}