サンプル
import java.io.File;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
public class Main {
public static void main(String[] args) {
load("etc/carenginestart2.wav");
}
private static void load(String soundFilePath) {
System.out.println("Start...");
try (AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(soundFilePath));
Clip line = AudioSystem.getClip();) {
line.open(audioInputStream);
line.start();
System.out.println("Playing...");
Thread.sleep(10L);
line.drain();
line.stop();
System.out.println("Stopped...");
} catch (final Exception ex) {
ex.printStackTrace();
}
}
}