本文实例讲述了Android开发实现读取Assets下文件及文件写入存储卡的方法。分享给大家供大家参考,具体如下:

调用一个反编译的.so文件,查看起加密和解密情况,需要解析上万的数组,而so文件加密解密都是通过Byte来进行,又需要把String字符串转化为 Byte,当把数据直接写在代码中就会提示多Byte数组过大。最后把数组写到Assets文件加下,读取txt文本文件。
读取Assets方法如下:
public String getFromAssets(String fileName) {
String result = "";
try {
InputStream in = getResources().getAssets().open(fileName);
// 获取文件的字节数
int lenght = in.available();
// 创建byte数组
byte[] buffer = new byte[lenght];
// 将文件中的数据读到byte数组中
in.read(buffer);
result = EncodingUtils.getString(buffer, ENCODING);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}