为什么不用java.util包的StringTokenizer?很好用的,根本不用取得那样复杂!

解决方案 »

  1.   

    your logic is a confusing one. Here give you an example here to deal with this type of problem:public static void main(String[] args) throws Exception{
      //temp = reader.readerLine();
      String temp="a piggy loves\r\t\r\ran\tegg\r\n";
      char ch;
      int cnt = 0;
      String word ="";

      while ((ch=temp.charAt(cnt++)) != '\n'){
         if((ch>='a'&& ch<='z')||(ch>='A'&&ch<='Z'))
            word = word + ch;
         else{
           if(!word.equals(""))
    System.out.println(word); //push to the stack here
           word = "";
         }
      }
    }
      

  2.   

    检查一下你的cnt,这问题调试一下就可以解决。