Recommended Posts

Hi all. I have a mid file posted in the same directory as my java appplet on my website. How do I access that file from my java program? Right now I have this:
try
{
URL url = new URL("http://seanstetris.50megs.com/");
tetris1 = getAudioClip(new URL(url, "tetris1.mid"));
tetris2 = getAudioClip(new URL(url, "tetris2.mid"));
tetris3 = getAudioClip(new URL(url, "tetris3.mid"));
}
catch(Exception e)
{
System.out.println("Error - files not loaded");
}
but every time, it prints out the error message and when it tries to play the music I get a nullPointerException. Please help. Thanks.

0

Share this post

Link to post

Share on other sites

I have done what your asking (loading from the url), but I don't have the source with me at work. I believe when I did it, I used getCodeBase() to get the proper URL from the Applet extended class. maybe something like