public class Test {
public static void main(String[] args) {
String s=null;
//字符缓冲区,System.in系统输入
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入:");
try {
//读取系统输入的数据
s=bf.readLine();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
//关闭缓冲区
bf.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
if(s!=null){
//如果是回车键,那么长度为0
if(s.length()==0){
System.out.println("你输入的是空格键");
}else {
System.out.println(s);
} }
}
}