第1个回答 2011-07-10
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
StringBuffer buffer = new StringBuffer();
String nextLine;
while (true) {
nextLine = scanner.nextLine();
if ("Esc".equals(nextLine)) {
break;
}
buffer.append(nextLine);
}
System.out.println("您输入的字符为: " + buffer.toString());
}本回答被提问者采纳
第2个回答 2011-07-10
package cn.njcit;
import java.util.Scanner;
public class Demo03 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请开始进行输入:");
StringBuilder sb = new StringBuilder();
while(true){
String s = in.nextLine();
if("Esc".equals(s)){
break;
}else{
sb.append(s);
}
}
System.out.println(sb);
}
}