how to set path for File Input Stream

Viewed 2175

i was trying to use a txt file but i got this eror "FileNotFoundException" but it was readable and it exist but on line FileInputStream i got that error whats the matter?

        System.out.println(Files.isReadable(Paths.get("I:/Code/Coding/src/Files/" + path + ".txt")));
        System.out.println(Files.exists(Paths.get("I:/Code/Coding/src/Files/" + path + ".txt")));
        FileInputStream f1=new FileInputStream("I:/Code/Coding/src/Files/" + path + ".txt");
        reader = new ObjectInputStream(f1);


java.io.FileNotFoundException: I:\Code\Coding\src\Files\Artists.txt (The system cannot find the path specified)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at sample.Datebase.Server.readFiles(Server.java:70)
    at sample.Datebase.Server.run(Server.java:99)
    at sample.Datebase.Server.main(Server.java:54)
Exception in thread "main" java.lang.NullPointerException
    at sample.Datebase.Server.readFiles(Server.java:94)
    at sample.Datebase.Server.run(Server.java:99)
    at sample.Datebase.Server.main(Server.java:54)
3 Answers
Related