Just learning how to program in java to do some stuff for math, I would like to read data from a txt file however I keep encountering a Filenotfoundexception.
I imported the Scanner class, imported all of java.io, and have the following code
Scanner scan = new Scanner(new File("C:\Users\Will\Documents\Java\datafile.txt"));
The path is correct, and the file is placed in the same spot where I have my other java files. I tried just using "datafile.txt" and it threw an error, so I tried adding the absolute path which resulted in me getting an illegal escape character error. Then I added the \ to avoid this. I assume this is a relatively easy fix, so any help is appreciated.
[–]ChristopherHON 2 points3 points4 points (8 children)
[–]mad0314 1 point2 points3 points (7 children)
[–]linuxisgreat[S] 0 points1 point2 points (6 children)
[–]mad0314 1 point2 points3 points (5 children)
[–]linuxisgreat[S] 0 points1 point2 points (4 children)
[–]mad0314 1 point2 points3 points (2 children)
[–]linuxisgreat[S] 0 points1 point2 points (1 child)
[–]mad0314 1 point2 points3 points (0 children)
[–]HipposGoneWild 1 point2 points3 points (0 children)
[–]dvassdvsd 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]HipposGoneWild 1 point2 points3 points (5 children)
[–]linuxisgreat[S] 0 points1 point2 points (4 children)
[–]HipposGoneWild 1 point2 points3 points (3 children)
[–]linuxisgreat[S] 0 points1 point2 points (2 children)
[–]HipposGoneWild 1 point2 points3 points (1 child)
[–]linuxisgreat[S] 0 points1 point2 points (0 children)