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!
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
Grant Murphy10,072 Points
Finishing TreeStory Code Challenge receiving a No File Exception
I am receiving a java.nio.file.NoSuchFileException: resources\censored_words.txt but the file is clearly in the resource folder. Been playing around with this and am at a loss all the imports look good that path seems right. Here is the full list of Errors.
Again I am really at a loss as to why this is being thrown.
Couldn't load censored words java.nio.file.NoSuchFileException: resources\censored_words.txt at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230) at java.nio.file.Files.newByteChannel(Files.java:361) at java.nio.file.Files.newByteChannel(Files.java:407) at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) at java.nio.file.Files.newInputStream(Files.java:152) at java.nio.file.Files.newBufferedReader(Files.java:2784) at java.nio.file.Files.readAllLines(Files.java:3202) at java.nio.file.Files.readAllLines(Files.java:3242) at com.teamtreehouse.Prompter.loadCensoredWords(Prompter.java:29) at com.teamtreehouse.Prompter.<init>(Prompter.java:21) at com.teamtreehouse.Main.main(Main.java:12) Exception in thread "main" java.lang.NullPointerException at java.util.AbstractCollection.addAll(AbstractCollection.java:343) at com.teamtreehouse.Prompter.loadCensoredWords(Prompter.java:34) at com.teamtreehouse.Prompter.<init>(Prompter.java:21) at com..Main.main(Main.java:12)
I added a
System.out.println(file.toAbsolutePath()); in the Prompter class.
And the path it prints is C:\Users\Grant\Desktop\TreeStory\resources\censored_words.txt
Again I am really at a loss as to why this is not reading the file.
Grant Murphy10,072 Points
I figured it out. I had to move the resources directory/folder up one level into the TreeStory2 directory/folder. I guess when I was unpacking the download it must have gotten moved. Now the path for the resources folder is TreeStory/TreeStory2/resources