java播放声音文件

package com.videoandsound;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import sun.audio.AudioPlayer;
import sun.audio.AudioStream;

public class Sound {

public Sound(){}

public static void main(String[] args) {

AudioStream as = null;

try {
System.out.println("555");
File fl = new File("E:\\报警声\\报警声.mid");

InputStream in = new FileInputStream(fl);
as = new AudioStream(in);
} catch (Exception er) {
}
if (as == null) {
System.out.println("silent");
} else {
AudioPlayer.player.start(as);
}

}

}

你可能感兴趣的:(java,sun)