Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Java can't find my file

import java.util.Scanner;
import java.io.*;

public class Project1 {
    public static void main (String [] args) throws IOException {
        Scanner keyboard = new Scanner(System.in);

        File file = new File("/MacintoshHD/Users/emilygalore/TextEdit/weasleystore.txt");
        Scanner scan = new Scanner(file);

        System.out.println(scan.nextLine());
    }
}

HELP! Not sure what I am doing wrong. I keep getting this error when I try to compile:

Exception in thread "main" java.io.FileNotFoundException: /MacintoshHD/Users/emilygalore/TextEdit/weasleystore.txt (No such file or directory)
    at java.base/java.io.FileInputStream.open0(Native Method)
    at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
    at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
    at java.base/java.util.Scanner.<init>(Scanner.java:639)
    at Project1.main(Project1.java:9)