Reputation: 55
Hi I was reading files using FileReader and Buffereader only and it was working perfectly
fr = new FileReader("C:\\Users\\User\\Documents\\Bus_Station\\Bus station\\tripFile");
br = new BufferedReader(fr);
But I want to read put these files in somewhere so I put them in Referecnced Libraries so I can read from them on any machine without path but it is not working :/
(File file = new File("tripFile.txt");
file.createNewFile();
fr = new FileReader(file););
Any help ?
Upvotes: 0
Views: 1576
Reputation: 1937
You should use resources.
URL fileURL = Resources.getResource("test.txt");
String text = Resources.toString(fileURL, Charsets.UTF_8);
How to add a resources folder
How do I add a resources folder to my Java project in Eclipse
adding resources in intellij for java project
How to create resource folder in Netbeans?
Upvotes: 2