-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileWrite.java
More file actions
29 lines (25 loc) · 913 Bytes
/
Copy pathFileWrite.java
File metadata and controls
29 lines (25 loc) · 913 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
import java.io.*;
import java.util.Scanner;
public class FileWrite {
public static void main(String[] args) {
try { Scanner scanner = new Scanner(System.in);
FileWriter wr = new FileWriter("list.txt", true);
PrintWriter pw = new PrintWriter(wr);
pw.println("====================");
for(int i=0; i<1; i++) {
System.out.print("\nName : ");
String name = scanner.next();
System.out.print("\nPrice : ");
double price = scanner.nextDouble();
Products p1 = new Products(name,price);
pw.print(p1.name+";"+p1.price);
}
pw.close();
scanner.close();
}
catch(Exception e)
{
System.err.println("error : "+e.getMessage());
}
}
}