我有一个Text Class
来自File
,因为很长一段时间我不想在一瞬间阅读File
!并且ListView
当滚动读取时仍然是来自File
的数据。
兄弟姐妹应该怎么做?
最诚挚的问候,Minallah Tofiq
public class MyText{
private AssetManager am;
private InputStream is ;
private BufferedReader br;
private String[] text;
private String Fulltext="";
private String linetext="";
public MyText(Context context,String FILE_URL) {
am = context.getAssets();
try {
is = am.open(FILE_URL);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.i("READ", "cannot read from file");
}
br=new BufferedReader(new InputStreamReader(is));
}
public void process(){
try {
while((linetext=br.readLine())!= null){
Fulltext+=linetext;
}
} catch (IOException e) {
// TODO Auto-generated catch block
Log.i("ERROR", "can't read in process method");
e.printStackTrace();
}
text=Fulltext.split("\\d+");
}
public String[] returnString(){
return this.text;
}
}
答案 0 :(得分:1)
您需要修改此行
while((linetext=br.readLine())!= null)
附加条件。如
while((linetext=br.readLine())!= null && (/*your conditional here*/))