- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFileIODemo5.java
More file actions
Latest commit
22 lines (21 loc) · 616 Bytes
/
Copy pathFileIODemo5.java
File metadata and controls
22 lines (21 loc) · 616 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
importjava.io.FileOutputStream;
importjava.io.BufferedOutputStream;
importjava.util.Scanner;
classFileIODemo5{
publicstaticvoidmain(String[] args){
try{
Scannersc = newScanner(System.in);
FileOutputStreamfin = newFileOutputStream("E:\\JAVA\\Java Classes Programs\\HelloIO5.txt");
BufferedOutputStreambuff = newBufferedOutputStream(fin);
System.out.println("Enter a message : ");
Stringmsg = sc.nextLine();
byte[] arr = msg.getBytes();
buff.write(arr);
buff.flush();
buff.close();
System.out.println("Success");
}catch(Exceptione){
System.err.println(e);
}
}
}