File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alternatives to getCodeBase()

 
Sean McGurk
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks!
By using the FileOutputStream class, I am able to write to a file located in the same directory as my applet. However, I am unable to read from a file as I am unable to create a URL.
I cannot state something like:

as the program that I am running is not an applet, but rather a java GUI program whose methods are accessed by an applet. It extends Frame, not applet.
Therefore, getCodeBase() is not recognised.
Are there any other protocols that do the same thing i.e. that allow reading from a file.
Regards,
Sean
 
Sean McGurk
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay;
I am now able to state the following:

where SpellCheck is the name of the applet that loads the GUI.
But I am still unable to state:

As this gives me an error message. Anyone know how I might work around this or suggest alternatives?
Regards,
Sean
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the proper syntax:
URL url = new URL(spellcheck.getCodeBase(), "words.txt");
But no matter how you spell it, or what mechanism you try, the sandbox rules still have the final say. A Java Application can write files, an applet running in the AppletView can write files, but an appplet in a web browser can only write files if it has been authorized and signed.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic