public static void copyRaw(AssetFileDescriptor fd, File destinationFile) throws IOException {
FileChannel sourceChannel =
new FileInputStream(fd.getFileDescriptor()).getChannel();
copyNIO(
sourceChannel, destinationFile,
fd.getStartOffset(), fd.getLength()
);
}
public static void copyNIO(FileChannel source, File destination, long startOffset, long length) throws IOException {
FileChannel destinationChannel = null;
try {
destinationChannel =
new FileOutputStream(destination).getChannel();
source.transferTo(startOffset, length, destinationChannel);
} finally {
// Tidy up...
}
}
AssetFileDescriptor and FileDescriptor
#android #fileDescriptor #assetFileDescriptor
#cesarnog
#android #fileDescriptor #assetFileDescriptor
#cesarnog
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.