I am trying to load a urscript file from the resources folder and execute it in the Installation node (similar to the ScriptWrapper Urcap example), but the file cannot be found from the Java code.
I saw @recognitionrobotics was having a similar issue, but with no resolution.
I placed the script file in the resources folder. Executing “jar tf” on the final jar file verifies the file is where it supposed to be, however my code cannot find it:
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();