List list=new ArrayList();
String str=null;
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
while ((str=in.readLine())!= null) {
list.add(str);
}
我还要判断!in.readLine().equals(""),请问怎么写?

解决方案 »

  1.   

    while (  ((str=in.readLine())!= null) && (!in.readLine().equals(""))  ) {
        list.add(str);
    }是这个意思吗?
      

  2.   

    或者while ((str=in.readLine())!= null) {
       if(!in.readLine().equals("")){  
          list.add(str);
       }
    }
      

  3.   


    String str = in.readLine();
    while(str != null && !(str.equals(""))) {
          list.add(str);
          str = in.readLine();
    }
      

  4.   

    以上都不行,试过吗?
    readLine一下就会跳过一行
    所以才写成这样(str=in.readLine())!= null3楼那样就读一行?
      

  5.   

    晕,你没看到下面还有一个str=in.readLine();
    这个很简单吧