我想将字节数组转换为 AudioInputStream。字节数组之前是从 *.wav 文件中填充的。我有以下代码:
public static AudioInputStream writeBytesBackToStream(byte[] bytes) {
ByteArrayInputStream baiut = new ByteArrayInputStream(bytes);
AudioInputStream stream = null;
try {
stream = AudioSystem.getAudioInputStream(baiut);
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if(stream.equals(null) || stream == null) {
System.out.println("WARNING: Stream read by byte array is null!");
}
return stream;
}
现在我只想把这个字节数组转换成一个AudioInputStream,但是抛出了一个UnsupportedAudioFileException:
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream
有人有想法吗?