Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I make a filename URL?

 
Steven Davidson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to play an AudioClip and the static method Applet.newAudioClip requires a URL. I am stumped as how to make a URL that represents a file on my computer. The API docs are not very usefull. Thanks.
Steven Davidson
 
Srinivas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A code like this should work i guess
File f = new File("mysound.au");
AudioClip theSound;
try {
theSound = Applet.newAudioClip(f.toURL());
} catch (java.net.MalformedURLException e) {
theSound = null;
}
if (theSound != null) {
theSound.play();
}
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic