reading from a file into an array java code example
Example 1: from file to array java
BufferedReader bufferedReader = new BufferedReader(new FileReader(myfile));
String []data;
data = new String[10];
for (int i=0; i<lines.size(); i++) {
data[i] = abc.readLine();
System.out.println(data[i]);
}
abc.close();
Example 2: from file to array java
ArrayList<String> result = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
while (br.ready()) {
result.add(br.readLine());
}
}