1BufferedReader bufferedReader = new BufferedReader(new FileReader(myfile));
2String []data;
3data = new String[10]; // <= how can I do that? data = new String[lines.size]
4
5for (int i=0; i<lines.size(); i++) {
6 data[i] = abc.readLine();
7 System.out.println(data[i]);
8}
9abc.close();
1ArrayList<String> result = new ArrayList<>();
2
3try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
4 while (br.ready()) {
5 result.add(br.readLine());
6 }
7}
8
1BufferedReader abc = new BufferedReader(new FileReader(myfile));
2List<String> lines = new ArrayList<String>();
3
4while((String line = abc.readLine()) != null) {
5 lines.add(line);
6 System.out.println(data);
7}
8abc.close();
9
10// If you want to convert to a String[]
11String[] data = lines.toArray(new String[]{});