I tried the following:
- absolute path;
- relative path;
- placed it in the root of a drive;
- placed on desktop so as to be more accessible;
I also did tests and the lines are read properly.
However, when submitting the material, I get time out (The program ran too long and was closed)
Any ideas or direction on how to solve this problem?
Thank you in advance.
package com.codegym.task.task15.task1525;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/*
File in a static block
*/
public class Solution {
public static List<String> lines = new ArrayList<>();
static
{
try(BufferedReader br =
new BufferedReader(new InputStreamReader(new FileInputStream(Statics.FILE_NAME)))){
while(true){
String line = br.readLine();
if(lines == null) break;
lines.add(line);
}
}catch (Exception ex){}
}
public static void main(String[] args) {
System.out.println(lines);
}
}