Java AudioClip Loads a clip from the resource directory.

PreviousNext

Loads a clip from the resource directory.

Parameter:

  • *filename
  • =>* The name of the file in the resource directory.
//package com.java2s;
import java.applet.Applet;
import java.applet.AudioClip;

import java.net.URL;

public class Main {
    private static String resources = "";
    private static ClassLoader loader;

    /**/*w   w   w.    d  e  m o 2    s.   c   o m */
     * 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);
    }
}
PreviousNext

Related