getResource() idiosyncracy

When porting java code to Processing sometimes it is necessary to use getResource() even though Processing does not have a ‘resources’ folder. In order to get a valid url in the following demo it is necessary to have the desired file lying free in the sketch folder as well as a copy of the file in a folder named ‘code’. There is an alternative work around by first getting a url from the file path string and then converting it back to a string. The second method is more code but will work on a single copy of the file in the sketch folder. Are there any other options that I am unaware of?

/*
 Requires one copy of the file lying free in the sketch folder
 and another copy of the file in a folder named 'code'
*/

import java.net.URL;

void setup() {
  String path = sketchPath() + "/myFile.txt";
  URL url = getClass().getResource(path);
  println("url =",url);
}