我将文件从eclipse中的Asset文件夹复制到Sdcard Genymotion虚拟设备,但是我收到了错误: java.io.FileNotFoundException:/storage/emulated/0/tesseract/tessdata/eng.traineddata:open failed:ENOENT(没有这样的文件或目录)。
请帮帮我 P / s:我在Manifest文件中添加了WRITE_EXTERNAL_STORAGE。 这是我的代码
donutProgress.setFinishedStrokeColor(Color.parseColor("#color_code"));
答案 0 :(得分:1)
使用此
AssetManager assetManager = getActivity().getAssets();
File file = new File(Environment.getExternalStorageDirectory()
+ "/tesseract/tessdata", lang + ".traineddata");
if (!(file.exists())) {
try {
InputStream in = assetManager.open("tessdata/" + lang
+ ".traineddata");
String sdCardPath = Environment.getExternalStorageDirectory()
+ "/tesseract/tessdata";
new File(sdCardPath).mkdirs();
File outFile = new File(sdCardPath + "/", lang + ".traineddata");
OutputStream out = new FileOutputStream(outFile);
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch (IOException e) {
Log.e("tag", "Failed to copy asset file: " + lang
+ ".traineddata", e);
}
}