首页 > 代码库 > java键盘录入

java键盘录入

System.out:标准输出设备(默认是:控制台)

System.in:标准输入设备(默认是:键盘)

---------------------

InputStream in = System.in;

int by = in.read();

sysout(by);

---------------------

InputStream in = System.in;

StringBuilder sb = new StringBuilder();

while(true){

int ch = in.read();

if(ch==’\r’){

        continue;

}

if(ch==’\n’){

      String s = sb.toString();

      if(“over”.equals(s)){

              break;

      }

      System.out.prinltn(s.toUpperCase());

      sb.delete(0, sb.length());

}

else

      sb.append((char)ch);

 

}