How to add a text file to the project?

I have been trying to add a file to my project. I have placed the file parallel to the src folder.

I am calling the file via this piece of code

String next = "";
File mappingsFile = new File("/mapping.json");
try {
    Scanner scanner = new Scanner(mappingsFile);
    next =;
} catch (FileNotFoundException e) {
    next = e.getLocalizedMessage();

I keep getting the FileNotFoundException, specifically that the specified path cannot be found?

How can I accomplish this?

1 comment
Comment actions Permalink

Okay so I got it to work finally using the answer provided here.

Message was edited by: Osama Rao


Please sign in to leave a comment.