如何实时控制应该读取多少文件



我有一个Text ClassFile读取,因为长时间的过程,我不想在一瞬间从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;
    }
}

您需要修改这一行

while((linetext=br.readLine())!= null)
带有附加条件的

。例如

while((linetext=br.readLine())!= null && (/*your conditional here*/))

最新更新