If you know that your file will live where your classes are, this directory will be in your class path. In this case, you can be sure that this solution will solve your problem:
URL path = ClassLoader.getSystemResource("myFile.txt"); if(path==null) { //The file was not found, insert error handling here } File f = new File(path.toURI()); reader = new BufferedReader(new FileReader(f));
Joel Westberg May 31 '12 at 9:19 a.m. 2012-05-31 09:19
source share