I am trying to read a file located at "C:\Users\Siddharth\Documents\aarti\yeh_vidhi_mangal.txt". Following code indicates that file exists
String filename = "C:\\Users\\Siddharth\\Documents\\aarti\\yeh_vidhi_mangal.txt";
File file = new File(filename);
System.out.println(file.exists());
but when I try to open the file using
FileInputStream in = new FileInputStream(file);
a FileNotFoundException
is thrown. Is this because access is denied? I checked file permissions and they are fine.
I have also tried working without eclipse. from the command line:
C:\Users\Siddharth\workspace\file_io_test\src>javac Foo.java Foo.java:16: error: unreported exception FileNotFoundException; must be caught o r declared to be thrown FileInputStream in = new FileInputStream(file); ^ 1 error