My application includes some .txt files that it needs to read.
I used to read them using the Inputstream:
Class c = this.getClass();
InputStream is = c.getResourceAsStream("/fileName.txt");
for efficiency reasons I needed to read them using the RandomAccessFile.
Because I can’t use the c.getResourceAsStream() I need to find another way to get the files.
I tried the following code:
Class c = this.getClass();
URL fileURL = c.getResource("/fileName.txt");
File file =new File(fileURL.getPath());
or
File file =new File(fileURL.toURI());
but wasn’t able to locate the file.
I think I’m missing something fundamental, can someone please help me?
Where do you have your file initially? Is it in raw folder, assets folder…?