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

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐