作者:l季莫_339 | 来源:互联网 | 2023-02-06 06:54
publicstaticvoidmain(String[]args)throwsIOException{readKey_2();}**得到键盘录入,并返回大写,输出over则停止
public static void main(String[] args) throws IOException {
readKey_2();
}
/*
* 得到键盘录入,并返回大写,输出over则停止
*/
public static void readKey_2() throws IOException {
//接收容器
StringBuilder sb = new StringBuilder();
InputStream in = System.in;
int ch = 0;
while((ch=in.read())!=-1){
if(ch=='\r')
continue;
if(ch=='\n'){
String temp = sb.toString();
if(temp.equals("over"))
break;
System.out.println(temp.toUpperCase());
sb.delete(0, sb.length());
}else
sb.append((char)ch);
}
}