import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Ex1 {
/**
* 编写程序,读取输入的数据,并判断数据,如果是exit就退出
*/
public static void main(String[] args) {
while(true) {
System.out.println("请输入一句话:");
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader bufR = new BufferedReader(isr);
try {
String row = bufR.readLine();
if("exit".equals(row)) {
System.out.println("成功退出!");
System.exit(0);
} else {
System.out.println(row);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
} |