Java examples for javax.sound.sampled:Audio
Loads a Audio clip from the resource directory.
//package com.java2s; import java.applet.Applet; import java.applet.AudioClip; import java.net.URL; public class Main { public static void main(String[] argv) throws Exception { String filename = "java2s.com"; System.out.println(loadClip(filename)); }/*from www .j a v a 2 s . c o m*/ private static String resources = ""; private static ClassLoader loader; /** * Loads a clip from the resource directory. * * @param filename * => The name of the file in the resource directory. */ public static AudioClip loadClip(String filename) throws Exception { URL url = loader.getResource(resources + filename); return Applet.newAudioClip(url); } }