Loading Script File from the Resources Folder

Maybe try accessing the text file by using a StreamReader. The object type “File” is usually used for files on the local file system, but the text file actually exists inside the .urcap archive, that is basically a .jar archive.

E.g. something like this (I’m sure there are many StreamReader examples out there):
java.net.URL fileURL = getClass().getResource("code.txt");
InputStreamReader inputReader = new InputStreamReader(getClass().getResourceAsStream(fileURL.getPath()));
BufferedReader reader = new BufferedReader(inputReader);

After that you can e.g. read in the individual lines of the text file, use a StringBuilder etc.
String line = reader.readLine();

4 Likes