Skip to content

Instantly share code, notes, and snippets.

@itog
Created December 28, 2009 15:38
Show Gist options
  • Save itog/264733 to your computer and use it in GitHub Desktop.
Save itog/264733 to your computer and use it in GitHub Desktop.
private void combineDevidedFiles(String destination, String devidedFilePrefix) {
File destFile = new File(destination);
destFile.mkdirs();
destination += devidedFilePrefix;
destFile = new File(destination);
InputStream input = null;
try {
AssetManager assetManager = context.getAssets();
OutputStream output = new FileOutputStream(destFile);
for (int i=1;i<=FILE_DIVIDED_NUM;i++) {
input = assetManager.open(DEVIDED_FILE_PREFIX + String.valueOf(i), AssetManager.ACCESS_STREAMING);
byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
int size;
while (true) {
size = input.read(buf);
if (size <= 0) {
break;
}
output.write(buf, 0, size);
}
input.close();
}
output.close();
} catch (Exception e) {
destFile.delete();
Log.w(TAG, e.getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment