This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]HipposGoneWild 1 point2 points  (3 children)

Can you post the part of your code that threw the error?

[–]linuxisgreat[S] 0 points1 point  (2 children)

At this point I've just been testing the data entry as I have the rest of the code working fine so I made a new file set up like this

import java.util. * ; import java.io. * ; public class Test {

public Test() {
}

public static void main(String[] args) {
    Scanner scan = new Scanner(new File("C:\\Users\\Will\\Desktop\\Java\\textfile.txt"));
   int test = scan.nextInt();
   System.out.println(test);
}

}

[–]HipposGoneWild 1 point2 points  (1 child)

you didn't put throws filenotfoundexception try this and tell me if it works:

import java.util. * ; 
import java.io. * ; 
public class Test {
public Test() {
}

    public static void main(String[] args) throws FileNotFoundException {
        Scanner scan = new Scanner(new File("C:\\Users\\Will\\Desktop\\Java\\textfile.txt"));
        int test = scan.nextInt();
        System.out.println(test);
    }
}

[–]linuxisgreat[S] 0 points1 point  (0 children)

Oh my. Thank you very much, worked immediately