我如何在android中附加两个音频文件。我试过这个,但它不起作用。请给我一个解决方案。我需要连接来自 ts A.mp3 和 B.mp3 的 sdcard 中的文件。当我合并连接方法调用时,我希望它们都作为 sdcard 中的单个文件,即 C.mp3 .... ……
File original= new File("/mnt/sdcard/A.mp3");
File temp=new File("/mnt/sdcard/B.mp3");
Log.i("...............",""+path);
try {
File outFile= new File("/mnt/sdcard/C.mp3 ");
DataOutputStream out=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outFile)));
// FileOutputStream out=new FileOutputStream(outFile);
//OutputStream out = new FileOutputStream(original,true);
int m,n;
m=(int) temp.length();
n=(int) original.length();
byte[] buf1 = new byte[m];
byte[] buf2 = new byte[n];
byte[] outBytes = new byte[m+n];
DataInputStream dis1=new DataInputStream( new BufferedInputStream(new FileInputStream(original)));
DataInputStream dis2=new DataInputStream( new BufferedInputStream(new FileInputStream(temp)));
dis1.read(buf1, 0, m);
dis1.close();
dis2.readFully(buf2, 0, n);
dis2.close();
out.write(buf1);
out.write(buf2);
out.flush();
//in.close();
out.close();
System.out.println("File copied.");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我需要将文件 A.mp3,B.mp3 合并到 C.mp3 ....