I've already compiled and run the program in NetBeans and it works normally, but when I run it through the terminal it always gives the IO Exception error. Is there any other way to read files without this error occurring?
My function to read file:
public static ArrayList<String> leArquivo(String nomeArq) throws FileNotFoundException, IOException {
int cont = 1;
ArrayList<String> frames = new ArrayList<>();
String linha = "";
FileReader arq = new FileReader(nomeArq.trim());
BufferedReader lerArq = new BufferedReader(arq);
while (linha != null) {
linha = lerArq.readLine();
frames.add(cont + "&" + linha + "\n");
cont++;
}
return frames;
}
function call:
try{
frame = leArquivo("sw.txt");
}catch (IOException e) {
Logger.getLogger(ServidorTeste.class.getName()).log(Level.SEVERE, null, ex);
}
Whenever I call the function, it drops in the Exception IO exception: