Reputation: 21
I imagine this would be a very rudimentary problem, since I am not quite familiar with applet deployments: I was made to convert a Swing application into an applet and embed it to a webpage. This applet constructs its knowledge base by reading lines from a text file (in the same directory as the .class file), and when I launched it from the applet viewer it reads the file with no problem.
Upon embedding, however, it fails to read the file and the exception handling is triggered. Perhaps this is one of those security restrictions?
I use File, FileReader, and LineNumberReader to read this document.
Additional problem: this also happens with images, where the applet would not run at all. I temporarily got around this by placing said images within an HTML file, but it could be done much better.
Upvotes: 2
Views: 427
Reputation: 1503729
Don't try to load it directly using a file - use Class.getResourceAsStream
and InputStreamReader
. In other words, load it as a resource rather than as a file.
Upvotes: 1