I want to read a text file from src folder of class activitydata. In order to do that, I wrote following code
ActivityData c = new ActivityData();
Class<? extends ActivityData> cls = c.getClass();
URL url = cls.getResource("file.txt");
System.out.println("Value = " + url);
Although I get the url in console, when I write following code I get exception:
Gson gson = new Gson();
JsonReader reader = new JsonReader(new FileReader(url.toString()));
Exception:
java.io.FileNotFoundException: file:\G:\Study%20Folder.......\file.txt (The filename, directory name, or volume label syntax is incorrect)