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