1.通过getResourceAsStream()读取 InputStream is =this.getClass().getResourceAsStream("/sounds/building.mp3"); InputStream bufferedIn = new BufferedInputStream(is); audioInputStream = AudioSystem.getAudioInputStream(bufferedIn);2.通过url来读取 URL url = getClass().getResource("/sounds/building.mp3"); audioInputStream = AudioSystem.getAudioInputStream(url );3.文件访问形式 File file = new File(filepath); audioInputStream = AudioSystem.getAudioInputStream(filepath);3.解决音频包的正确引用 jl1.0.jar tritonus_mp3 tritonus_share.jar |
|