频道栏目
首页 > 资讯 > 其他 > 正文

EncodingUtils 过时

17-06-08        来源:[db:作者]  
收藏   我要投稿

EncodingUtils 过时,EncodingUtils:deprecated 过时,API level 21之后可用,

new String(byte[] data, String charsetName)这个构造函数,可以运行在任意API Level

public static String readFileFromAssets(Context context,String fileName)
{ 
String res="";   
try{
  InputStream in = context.getResources().getAssets().open(fileName);   
 
  int length = in.available();           
  byte [] buffer = new byte[length];          
 
  in.read(buffer);              
  in.close();  
  //res = EncodingUtils.getString(buffer, "UTF-8");//EncodingUtils:deprecated  过时,API level 21之后是不可以的   
  res = new String(buffer, "UTF-8");//用new String可以运行在任意API Level
  
 }catch(Exception e){   
     e.printStackTrace();          
  } 
return res;
}
相关TAG标签
上一篇:URI和URL、URN
下一篇:运行循环-RunLoop
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站