-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileStream.java
More file actions
34 lines (29 loc) · 903 Bytes
/
Copy pathFileStream.java
File metadata and controls
34 lines (29 loc) · 903 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.ArrayList;
import java.util.Scanner;
public class FileStream {
private ArrayList<String> list = new ArrayList<>();
public FileStream(String directory, String fileName) {
readFile(directory, fileName);
}
public ArrayList<String> getUrls() {
return list;
}
private void readFile(String directory, String fileName) {
File file = new File(directory, fileName);
Scanner read = null;
try {
read = new Scanner(file.getAbsoluteFile());
while (read.hasNext()) {
list.add(read.nextLine());
}
} catch (FileNotFoundException e) {
System.err.println("Error readFile" + e.getMessage());
} finally {
if(read != null) {
read.close();
}
//int listCount = list.size();
}
}
}