码迷,mamicode.com
首页 > 其他好文 > 详细

回车键

时间:2014-06-25 11:54:17      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:class   数据   string   os   line   new   

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);    

    }   }  

    }

}

回车键,布布扣,bubuko.com

回车键

标签:class   数据   string   os   line   new   

原文地址:http://www.cnblogs.com/danmao/p/3807190.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!