读取dat文件

来源:互联网 发布:淘宝店铺提取软件 编辑:程序博客网 时间:2024/05/16 02:20
/**
* 读取assest下的dat文件
* */
private static String readPromoter(Activity activity) {
String fileName = "promoter.dat"; //文件名字
String res="";
try{


//得到资源中的asset数据流
InputStream in = activity.getResources().getAssets().open(fileName);
int length = in.available();
byte [] buffer = new byte[length];
in.read(buffer);
in.close();
res=new String(buffer ,"UTF-8");
LogUtils.e("分销人员id", res);
dat=res;
}catch(Exception e){
e.printStackTrace();
}
return res;
}