gpt4 book ai didi

java - 在 Android 中连接两个 MP3

转载 作者:行者123 更新时间:2023-12-01 12:37:47 26 4
gpt4 key购买 nike

我看了几页有关它的内容,但我找到了问题的解决方案,想将两个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();
}


}

最佳答案

创建文件而不是目录!

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();
}

关于java - 在 Android 中连接两个 MP3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25417588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com