android系统中*.bin文件读取时乱码问题

阿军 2013-05-02 09:42:41
大家好,我最近想通过程序查看android系统中的*.bin文件里的数据信息,我试过用notepad和ue查看软件打开后看到都是乱码。
后来我想通过android程序来读取查看不知是什么原因看到的也全部是些乱码,我的查看方法如下:
从android系统中复制出*.bin文件放到我项目工程中assets文件中,读取代码如下:

private AssetManager am;
private InputStream is;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

readerBin();
}

private void readerBin() {

am = this.getResources().getAssets();
try {
is = am.open("xtra.bin");
if (is != null) {
Log.e("TAG", "It worked!");
}
String str=readTextFile(is);
Log.e("TAG", str);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

private String readTextFile(InputStream inputStream) {

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte buf[] = new byte[1024];
int len;
try {
while ((len = inputStream.read(buf)) != -1) {

String text = new String(buf, "UTF-8");
Log.i("TAG", text);
outputStream.write(buf, 0, len);

}

outputStream.close();

inputStream.close();

} catch (IOException e) {

}
return outputStream.toString();
}

但最后读取出来的数据也是些乱码,不知道是何原因?请大家帮忙一些。。。
...全文
485 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
阿军 2013-05-06
  • 打赏
  • 举报
回复
是android系统(小米系统)手机中agps定位时产生的文件数据,我想查看文件中的数据对我现在做定位有没有帮助,我也并不知道他的编码格式。不知道还没有没别的方法可以读取正常显示。
CyberLogix 2013-05-05
  • 打赏
  • 举报
回复
bin二进制文件,你读取他想给你什么呢
兔子和小鱼干 2013-05-03
  • 打赏
  • 举报
回复
bin是二进制文件
儿大不由爷 2013-05-03
  • 打赏
  • 举报
回复
你的bin文件里面保存的数据是什么编码啊? 你的解码必须和编码一致才行。

80,471

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧