//filename: A.java
public class A {
/**
* 调用方法获取输入的字符串
*/
public static String getLines(String end)
throws Exception {
StringBuffer sb = new StringBuffer();
Scanner reader = new Scanner(System.in);
String line;
while (reader.hasNext()) {
line = reader.nextLine();
sb.append(line);
if (line.endsWith(end)) {
break;
}
}
return sb.toString();
}
//以下是调用代码
public static void main(String[] args) {
try {
String lines = getLines("end");
System.out.println(lines);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}