File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I make a filename URL?

 
Steven Davidson
Greenhorn
Posts: 6
  • 0
  • 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
  • 0
  • 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();
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic