I'm trying to read a file ( arquivo.txt
) that is in the same folder as my class, but I run the code an error appears that did not find the file. Could someone check what's wrong? Thanks in advance.
My arquivo.txt
:
Industria;2;90000
Comercio;3;45000
Residencia;1;3000
My Java class:
package jogo;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
public class Tabuleiro {
private static Scanner scanner;
public static void main(String[] args) {
try {
scanner = new Scanner(new FileReader("arquivo.txt"));
scanner = scanner.useDelimiter(";");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while (scanner.hasNext()) {
String imovel = scanner.next();
String posicao = scanner.next();
String valor = scanner.next();
System.out.println(imovel);
System.out.println(posicao);
System.out.println(valor);
}
}
}