• 9
• 9
• 11
• 12
• 9

# [java] Another Newbie to applet question

This topic is 4239 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

What is the best way to retrieve a file associated with an applet (that is in the same or relative directory) from where the applet is served up from? Can and does an applet need to create a socket and then do an HttpGet to get the contents of a file? Or is this ability some how built into the Applet stuff? Sorry if this is stuff that is obvious in the applet package api doc. Some times if you ask a question you get an answer and some other useful stuff...sometimes. Thanks a lot, L-

##### Share on other sites
include it in the jar. Then you access the file just normal inside the jar. So let say you have package xxx and class A with a gif.

+ xxx
+ A.class
+ img.gif

class A
{
//...
//inside A
URL img = this.getClass().getRessource("./img.gif");

}

new URL(getDocumentBase(), "myfile.txt").openStream();