-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.java
More file actions
32 lines (25 loc) · 776 Bytes
/
Copy pathfile.java
File metadata and controls
32 lines (25 loc) · 776 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
import java.io.*;
import java.util.*;
public class file {
public static void main(String[] arg) {
try {
int score;
int your_score;
File highscores = new File("Highscores.txt");
highscores.createNewFile();
score = 5;
FileWriter writer = new FileWriter("Highscores.txt");
writer.write(score);
score = 0;
Scanner reader = new Scanner(highscores);
while (reader.hasNextLine()) {
int data = reader.nextInt();
score = data;
}
System.out.print("score: ");
System.out.println(score);
} catch (IOException e) {
System.out.println("Error");
}
}
}