Using a file from the web
Hi all,
I am interacting with a third-party program (i.e., one that I can't edit) that needs the path of a file (specifically, a NetLogo file).
If I set
path ="/Absolute/path/on/computer/myfile.nlogo"
NetLogo.open(path);
Everything works well. However, now I want the myfile.nlogo file to reside on the web.
At first I naiively thought I could simply usepath ="http://url/to/myfile.nlogo";
NetLogo.open(path);
but doing this gives me a java.io.FileNotFoundException error.
So then I read further into how to open a file from a URL, and it looked as if I ought to be able to do this:URL url =new URL("http://url/to/myfile.nlogo");
File file = (File)url.getContent();
NetLogo.open(file.getAbsolutePath());
but doing that gives me a ClassCast exception when setting the file.
How can I use a file on the web in my java program?
Thanks for any help!
Sam

