I am new to ANT and having some trouble handling static files which I need to read via my Java code. I have the following structure:
build main example resository SomeClass.class data data.json src example repository SomeClass.java test In SomeClass.java I need to read the data.json file but I am getting error in resolving path. I think its related to ant somehow.
public class SomeClass { class SomeClass extends ArrayList<Quote> {} public Quote[] all() { String path = "../../../data/data.json"; Gson gson = new Gson(); try { BufferedReader br = new BufferedReader(new FileReader(path)); return gson.fromJson(br, Quote[].class); } catch (IOException e) { e.printStackTrace(); } return new Quote[]{}; } } I am getting the following error:
java.io.FileNotFoundException: I think since ant it putting the files in build folder hence I may need to put my files somewhere there too, I have tried that too but I think I need some more help.