Java 通过AudioSystem.getAudioInputStream(文件)读取MP3文件时出现异常

Java 通过AudioSystem.getAudioInputStream(文件)读取MP3文件时出现异常,java,audio,mp3,javasound,javax.sound.sampled,Java,Audio,Mp3,Javasound,Javax.sound.sampled,我试图通过javax.sound.sampled.AudioSystem类读取MP3文件,但我得到了一个不支持的数据文件异常。 我尝试读取音频文件的代码如下所示:- AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file); 我得到以下例外情况:- javax.sound.sampled.UnsupportedAudioFileException: could not get audio inp

我试图通过javax.sound.sampled.AudioSystem类读取MP3文件,但我得到了一个
不支持的数据文件异常
。 我尝试读取音频文件的代码如下所示:-

AudioInputStream audioInputStream = 
    AudioSystem.getAudioInputStream(file);
我得到以下例外情况:-

javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file

AudioSystem类不支持mp3格式吗?如果不是,那么它支持什么格式?还是我在这里搞错了?

不,它不支持MP3(因此出现了
不支持的DaudioFileException
)。支持的文件非常基本(WAV等),因此对于任何高级编解码器,您都需要单独的库。

有没有办法通过Java读取mp3格式文件而不使用第三方库?只有在您自己编写库的情况下才可以。@Vinettygi看一下类似于@greg-449的内容似乎很有用。我试试看。感谢您提供此问题的原因和解决方案(使用
mp3plugin.jar
)。。