Applet accessing files outside its JAR?
843807Oct 27 2009 — edited Nov 11 2009I'm having a lot of trouble figure out how to do this. I've done a lot of searching on the web and asked a few friends but nobody seems to have a good answer for how my applet on a web server can access a file outside the jar.
The situation is that I have an applet (called jviewer) housed in a JAR (jviewer.jar) on a web server (say, for example, /u/bob/public_html/gui/) that needs to be able to access a binary OBJ file, here-after known as output00.bobj, in the same directory (/u/bob/public_html/gui/). The code doing this accessing is given below.
String filename = getParameter("file");
//URL myurl = this.getClass().getResource(filename);
//URL myurl = this.getCodeBase();
String filepath = "" + myurl.toString() + filename;
triangles = read_file.read_bobj(filepath);
vertices = read_file.vertices;
Frame frame = new MainFrame(view = new viewer(triangles, vertices), 512, 512);