日期:2014-05-18 浏览次数:20882 次
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String read=null;//声明字符串变量存放读出字符串
ArrayList<String> list = new ArrayList<String>();
while((read=reader.readLine())!=null && !"quit".equals(read))//直读 (遇到quit就退出)
{
list.add(read);
}
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = null;
int nullLineCount = 0;
while(true){
line = reader.readLine();
if(line==null
------解决方案--------------------
line.trim().length()==0){
System.out.println();
nullLineCount++;
if(nullLineCount==2){
break;
}
}else{
System.out.println(line);
nullLineCount=0;
}
}
}