Jump to content
  • Advertisement
Sign in to follow this  
Lucidquiet

[java] Another Newbie to applet question

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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");

}

Share this post


Link to post
Share on other sites
As Paclaw said, it is better to package everything up in a jar. However to do it the way you want just do something like this:

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


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!