aspose file tools
The moose likes Beginning Java and the fly likes How do I make a filename URL? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How do I make a filename URL?" Watch "How do I make a filename URL?" New topic
Author

How do I make a filename URL?

Steven Davidson
Greenhorn

Joined: Feb 02, 2002
Posts: 6
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

Joined: Feb 01, 2002
Posts: 9
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();
}


Srinivas
 
 
subject: How do I make a filename URL?
 
Similar Threads
Working with Webservices in J2ME
How to JTabel show more than 10 colums in JTable with resonable visual data at a time?
Help.
Steal a session
Where is the locking test harness