Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getCodeBase() rules

 
Nelson Nadal
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it necessary that the applet class and the file that it reads must be in the same directory like this...
URL textURL = new URL( getCodeBase() , "test.txt" );
Can't I do this?
URL textURL = new URL( getCodeBase() , "subdir/test.txt" );
Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can indeed do that, but only if "subdir" is a subdirectory of the directory the Applet's .class file was downloaded from; otherwise you may have to modify the URL's path a bit. You've also got getDocumentBase() to play with.
 
Nelson Nadal
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Sir Ernest.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic