Skip to content

Instantly share code, notes, and snippets.

@hsmnzaydn
Created April 19, 2018 11:08
Show Gist options
  • Save hsmnzaydn/2284728212acfad16431fde669a1d0c4 to your computer and use it in GitHub Desktop.
Save hsmnzaydn/2284728212acfad16431fde669a1d0c4 to your computer and use it in GitHub Desktop.
private MappedByteBuffer loadModelFile(Activity activity, String MODEL_FILE) throws IOException {
AssetFileDescriptor fileDescriptor = activity.getAssets().openFd(MODEL_FILE);
FileInputStream inputStream = new FileInputStream(fileDescriptor.getFileDescriptor());
FileChannel fileChannel = inputStream.getChannel();
long startOffset = fileDescriptor.getStartOffset();
long declaredLength = fileDescriptor.getDeclaredLength();
return fileChannel.map(FileChannel.MapMode.READ_ONLY, startOffset, declaredLength);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment