我看了几页关于它的内容,但我找到了问题的解决方案,希望将两个mp3曲目加入到一个,但当时他写出输出(juntos4.mp3,它只是歌曲,某人可以帮帮我吗?
“我的”代码......
FileInputStream fis1 = new FileInputStream("/sdcard/1408586436107.mp3"); // first source file
FileInputStream fis2 = new FileInputStream("/sdcard/1408586281745.mp3");//second source file
SequenceInputStream sis = new SequenceInputStream(fis1, fis2);
FileOutputStream fos = new FileOutputStream("/sdcard/juntos4.mp3");//destinationfile
int temp;
try {
while ((temp = sis.read())!= -1){
fos.write(temp);
}
fis1.close();
fis2.close();
sis.close();
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
答案 0 :(得分:1)
创建FILE而不是目录!
newFile.createNewFile();
FileInputStream fistream1 = new FileInputStream(newFile1 ); // first source file
FileInputStream fistream2= new FileInputStream(newFile2 );//second source file
Vector<FileInputStream> v = new Vector<FileInputStream>();
v.add(fistream1);
v.add(fistream2);
SequenceInputStream sistream = new SequenceInputStream(fistream1, fistream2);
if(!newFile.exists()){
newFile.createNewFile();
FileOutputStream fostream=new FileOutputStream(newFile, true);
int temp;
while( ( temp = sistream.read() ) != -1)
{
System.out.print( (char) temp ); // to print at DOS prompt
fostream.write((byte)temp); // to write to file
}
fostream.close();
sistream.close();
fistream1.close();
fistream2.close();
}