import java.io.*;
class File2And
{
public void and()throws Exception{
BufferedInputStream input1 = new BufferedInputStream(new FileInputStream(new File("音频文件1的路径及文件名"))); //路径格式:D://java//1.MP3
BufferedInputStream input2 = new BufferedInputStream(new FileInputStream(new File("音频文件2的路径及文件名")));
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File("合并后的音频文件的路径及文件名")));
byte[] byt = new byte[1024];
int len;
while ((len=input1.read(byt)) != -1)
{
out.write(byt,0,byt.length);
out.flush();
}
while ((len=input2.read(byt)) != -1)
{
out.write(byt,0,byt.length);
out.flush();
}
input1.close();
input2.close();
out.close();
}
public static void main(String[] args) throws Exception
{
new File2And().and();
}
}
要注意文件路径的书写,写错了就会报错 我验证过了 可以完好的合并两个音频文件
楼主速度采纳了 写了半天劳动成果不被重视偶会很伤心呢,伤心欲绝也许以后就不打算在网上帮人了,为了让世界充满爱,为了世界上多一点正能量,采纳吧...........