-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSaveFile.java
More file actions
34 lines (27 loc) · 737 Bytes
/
SaveFile.java
File metadata and controls
34 lines (27 loc) · 737 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
34
import java.io.*;
import java.util.*;
public class SaveFile{
User user;
String fileName;
PrintWriter outputStream;
public SaveFile(User user){
this.user=user;
}
public void play() {
Print print=new Print("saveFile","Saved:)");
print.play();
fileName= "user.txt";
outputStream= null;
try{
outputStream= new PrintWriter(fileName);
}
catch(FileNotFoundException f){
System.out.println("Error opening the file"+ fileName);
System.exit(0);
}
Scanner keyboard= new Scanner(System.in);
outputStream.println(user.getMoney());
outputStream.println(user.getRodLevel());
outputStream.close();
}
}