KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have the following code to read a text file. public static void main(String[] args) { try { Scanner in = new Scanner(new FileReader("input.txt")); while(in.hasNext()) { System.out.println(in.next()); } } catch (FileNotFoundException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } I have my project structure set up as follows: build/ directory contains class dist/ directory contains the jar file src/ directory contains source input.txt the text file to read If I put my textfile input.txt into a directory called test which is of the same directory as build , dist , and src , what should go into the parameter of filereader so that I can still find this file?
Tags (comma-separated)
Save Edits
Cancel