-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
25 lines (22 loc) · 767 Bytes
/
Test.java
File metadata and controls
25 lines (22 loc) · 767 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
package java_core_basic;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
public class Test {
public static void main(String[] args) {
try {
BufferedReader reader = new BufferedReader(new FileReader("data/input.txt"));
String line;
ArrayList<Integer> arr = new ArrayList<Integer>();
while ((line = reader.readLine()) != null) {
int num = Integer.parseInt(line.trim());
arr.add(num);
}
reader.close();
// sử dụng mảng arr ở đây
} catch (IOException e) {
System.out.println("Không thể đọc file");
}
}
}