import java.io.IOException;
import java.io.InputStream;
public class SplitDemo {
public static void main(String[] args) throws IOException {
InputStream in=System.in;
StringBuilder sb=new StringBuilder();
while(true){
char ch=(char)in.read();
//if(ch!='\r'&&ch!='\n') 代码在这里写就没问题
// sb.append(ch);
if(ch=='\r')
continue;
if(ch=='\n'){
String s=sb.toString();
if(s.equals("over"))
{
sb.delete(0, sb.length());
break;
}
System.out.println(s);
sb.delete(0, sb.length());
ch=0;
}
sb.append(ch); <但是写在这里就不行了>
//System.out.println("append end:"+sb.toString());
}
}
}
帮帮忙讲明白吧! |