1

I am trying to read a file from the source folder, both the java file and text files are same location but program shows FileNotFoundException

Where should i put input file so program can find it?

enter image description here

Girdhar Singh Rathore
  • 5,030
  • 7
  • 49
  • 67

2 Answers2

3

Either you have to use absolute path or put you text file in root folder. In your case put your txt file in BasicIO.

anand mishra
  • 900
  • 1
  • 11
  • 30
0

Have you tried this? FileInputStream("hello.txt"), doesn't work unless I specify an absolute path (C:\User\Documents etc) Instantiate a File object with relative path ./name.txt e.g.:

File file = new File("./myfile.txt");

Make sure myfile.txt is in the root project folder.

Community
  • 1
  • 1
allegory
  • 124
  • 1
  • 1
  • 10