I am trying to read from a file using Java. But it shows an error saying that system cannot find the specified file, when the file is lying in the same directory as the source f
There is not problem in your code, its just that when you do not give any file location The System tries to find the file in the Project root.
Check the image below:
EDIT: If you are using Eclipse, it should be like this. WHt dont you just paste a screenshot of your project directory.
C:\CSMAIN\ws\TestFile\src\file.java
C:\CSMAIN\ws\TestFile\RoomList.txt
If you are not using any IDE then, you can create a project and put both the files in the project directory and compile it using command prompt and run it. It works.
You should escape the slashes, try changing your code to:
br = new BufferedReader(new FileReader("C:\\semester 2\\java\\PROJECTS\\BookingSystem\\file.java"));