File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Reading file from the Internet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Reading file from the Internet" Watch "Reading file from the Internet" New topic

Reading file from the Internet

Gabriel Soler

Joined: Nov 11, 2002
Posts: 1
I have an applet with the following code:
String theFile, thePath, theWorkFile;
theFile = getParameter("myfile");
thePath = getParameter("mypath");
theWorkFile = thePath + theFile;
FileInputStream myStream = new FileInputStream(theWorkFile);
I have no problem when I run this locally. The applet is able to read the file. But when it runs from the Internet it does not work. I get the following error: access denied ( http:\\mydata.txt read)
Read and write are among the file attributes. I have tried many other ways to get this applet to work from my website, but no luck. Can anyone help me with the solution?
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
Applets may only access web accessable content (unless you jump through some security hoops)... so you should convert your file path into a URL that points to the file you want and then call the openStream() method on the url.
Hope this helps.

- Chris Stehno, SCPJ
I agree. Here's the link:
subject: Reading file from the Internet
It's not a secret anymore!