连接两个byte数组的简单方法是什么?
说,
byte a[];
byte b[];
Run Code Online (Sandbox Code Playgroud)
如何连接两个byte数组并将其存储在另一个byte数组中?
我有两个byte[]长度未知的数组,我只想将一个附加到另一个的末尾,即:
byte[] ciphertext = blah;
byte[] mac = blah;
byte[] out = ciphertext + mac;
Run Code Online (Sandbox Code Playgroud)
我试过使用arraycopy()但似乎无法让它工作.
如何将两个音频文件合并到android平台中的单个文件中.也就是说,如果我有两个音频文件,即A和B.请给我代码来创建一个新的音频文件C,在A之后由B附加.是否需要将音频文件转换为字节/短数组? ..
我确实喜欢这个,但它只播放第一个文件.
File firstFile=new File("/mnt/sdcard/Android/data/Dictation/Audio/Dict136.3gp");
File secondFile=new File("/mnt/sdcard/Android/data/Dictation/Audio/Dict139.3gp");
System.out.println("1 file:::::"+firstFile+"\n 2nd file::"+secondFile);
FileInputStream fistream1;
try {
fistream1 = new FileInputStream(firstFile);
FileInputStream fistream2 = new FileInputStream(secondFile);//second source file
SequenceInputStream sistream = new SequenceInputStream(fistream1, fistream2);
FileOutputStream fostream = new FileOutputStream("/mnt/sdcard/Android/data/Dictation/Audio/merged.3gp");//destinationfile
int temp;
while( ( temp = sistream.read() ) != -1)
{
System.out.print( (char) temp ); // to print at DOS prompt
fostream.write(temp); // to write to file
}
filePath="/mnt/sdcard/Android/data/Dictation/Audio/merged.3gp";
playAudio(filePath);
fostream.close();
fistream1.close();
fistream2.close();
Run Code Online (Sandbox Code Playgroud)
提前致谢.