file123.bin文件预置进assets文件夹下
copyMcuFile("file123.bin", new File(getFilesDir()+ "/file123.bin"));
private void copyMcuFile(String sourceFileName, File dest) throws IOException {
InputStream in = null;
OutputStream out = null;
final int READ_BUFFER_SIZE = 4 * 1024 * 1024;
try {
in = getAssets().open(sourceFileName);
out = new FileOutputStream(dest);
byte[] buf = new byte[READ_BUFFER_SIZE];
int bytesRead;
while ((bytesRead = in.read(buf)) > 0) {
out.write(buf, 0, bytesRead);
}
Log.d(TAG,"copyFile finished");
} catch (Exception e) {
Log.d(TAG,"copyFile Exception:"+e);
} finally {
if(in != null) {
in.close();
}
if(out != null) {
out.close();
}
}
}