I'm getting the error Exception in thread "main" java.nio.file.NoSuchFileException
but I'm sure the file exists at the given location C:\\Users\\Admin\\Desktop\\Java.txt"
.
Why do I still get this error?
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Scanner;
public class ReadData {
public static void main(String[] args) throws IOException {
Scanner file = new Scanner(Paths.get("C:\\Users\\Admin\\Desktop\\Java.txt", "UTF-8"));
int int_value;
while ((file.hasNextInt())) {
int_value = file.nextInt();
System.out.println("Data:" + int_value);
}
file.close();
}
}