I have a jar compiled with core jdk.
It contains a java class which reads a txt file.
It has a test which proves that this class works correctly.
If I include this jar in my android project and then call the java class that reads the txt file. It fails reporting: java.io.FileNotFoundException and adding a ‘/’ to the path of the txt file which I wanted to load.
Is Android’s security model stopping the txt file from being read?
My Project structure:
Android Module:
src/Loader.java [calls GetName.java]
Java Module:
test/TestGetName.java [calls GetName.java]
src/GetName.java
resources/names.txt
Summary:
TestGetName.java works
Loader.java fails. A FileNotFoundException is thrown inside GetName
Figured it out in the end. I need a condition to see if I am loading the file locally or as a resource. There is probably a neater way to do this without using a conditional.
Thanks for the hints about reading as a resource user77777777