0
I have already compiled and run the program in Netbeans and it works normally, but when I run it through the terminal always gives the IO Exception error. Is there any other way to read files without this error?
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, falls into the exception of IO Exception:
The solution below did not meet you?
– user28595
Yes, you did, thank you!
– Éowyn