Android java从assets->fast中打开
public static String openAssetFile(Context ctx) {
BufferedReader br=new BufferedReader(new InputStreamReader(ctx.getResources().openRawResource(R.raw.hung)));
String readLine;
String sout="";
try {
while ((readLine = br.readLine()) != null) {
sout+=readLine;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return sout;
}
这不起作用,它冻结了,我的 xml 文件大约有 300 kb。
我该如何处理这个问题?
public static String openAssetFile(Context ctx) {
BufferedReader br=new BufferedReader(new InputStreamReader(ctx.getResources().openRawResource(R.raw.hung)));
String readLine;
String sout="";
try {
while ((readLine = br.readLine()) != null) {
sout+=readLine;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return sout;
}
this not work, its freezes, my xml file is about 300 kb.
how i can handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用这样的 StringBuffer ,你这样做的方式非常慢
Try using a StringBuffer like this, the way you are doing it is very slow
尝试将其放入“/xml”并调用
Resources.getXML()
,或将其放入“/assets”?Tried putting it in "/xml" and calling
Resources.getXML()
, or putting it in "/assets"?