public boolean readFilefromAssets(Context context, String assetsFile){
InputStream stream = assets.open(assetsFile)
if (stream == null) {
Toast.makeText(context, "assets no such file", Toast.LENGTH_SHORT)
.show()
return false
}
String folder = File.separator + "mnt" + File.separator + "sdcard"
+ File.separator + "Android" + File.separator + "data"
File f = new File(folder)
if (!f.exists()) {
f.mkdir()
}
String filePath = File.separator + "mnt" + File.separator + "sdcard"
+ File.separator + "Android" + File.separator + "data"
+ File.separator + "file.text"
File file = new File(filePath)
OutputStream output = null
try {
output = new FileOutputStream(file)
final byte[] buffer = new byte[1024]
int read
while ((read = stream.read(buffer)) != -1) {
output.write(buffer, 0, read)
}
output.flush()
} catch (Exception e1) {
e1.printStackTrace()
} finally {
try {
output.close()
stream.close()
} catch (IOException e) {
e.printStackTrace()
}
}
}
从上到下,根据贴出的第2张图中Console口信息,在运行java命令时,需用到 D:/(省略中间目录)/android-19/lib/dx.jar java包,但这个文件访问不了(出错信息提示的)。请确认文件是否存在。
如果文件存在,但问题还出现,根据你提供的第四张图,请确认工程的API级别的是android2.3.3还是android4.4.2,根据图片2中信息,打包需要用到android4.4.2,而工程api是android2.3.3,是否是这个原因导致?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)