aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Reading file from the Internet" Watch "Reading file from the Internet" New topic
Author

Reading file from the Internet

Gabriel Soler
Greenhorn

Joined: Nov 11, 2002
Posts: 1
Hi:
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:
java.security.AccessControlException: access denied (java.io.FilePermission http:\www.mysite.com\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?
Thanks,
Gabriel
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: http://aspose.com/file-tools
 
subject: Reading file from the Internet
 
Similar Threads
Signed applet and printing
Fastest File Read Method
WSAD - Reading Property Files
FileOutputStream
Beanutils.populate error with file upload control