byte fileContent[]=null;
FileInputStream ins;
FileOutputStream fos = null;
try{
fos = new FileOutputStream(getFilename(),true);
Log.i(TAG, "OutputFile created");
}
catch (FileNotFoundException e1){
// TODO Auto-generated catch block
Log.i(TAG, "OutputFile Not created");
e1.printStackTrace();
}
for(int i=1;i<listOfFilesToCombine.size();i+=2){
try{
File f=new File(listOfFilesToCombine.get(i));
Log.v("TAG", "File Length:"+f.length());
fileContent = new byte[(int)f.length()];
ins=new FileInputStream(listOfFilesToCombine.get(i));
int r=ins.read(fileContent);
Log.v("TAG", "Number Of Bytes Readed:"+r);
if(i>1){
byte[] headerlessFileContent = new byte[fileContent.length-6];
for(int j=6; j<fileContent.length;j++){
headerlessFileContent[j-6] = fileContent[j];
}
fileContent = headerlessFileContent;
}
fos.write(fileContent);
Log.v("TAG", "File"+i+"is Appended");
}
catch (FileNotFoundException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try{
fos.close();
Log.v("Record Message", "===== Combine File Closed =====");
}
catch (IOException e){
// TODO Auto-generated catch block
e.printStackTrace();
}