package cn.itcast.io.p1.transstream.demo;
import java.io.IOException;
import java.io.InputStream;
public class ReadKey {
public static void main(String[] args) throws IOException {
readKey2();
}
public static void readKey2() 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("over".equals(temp))
break;
System.out.println(temp.toUpperCase());
sb.delete(0, sb.length());
}
else
sb.append((char)ch);
}
}
public static void readKey() throws IOException {
InputStream in = System.in;
int ch = in.read();
System.out.println(ch);
int ch1 = in.read();
System.out.println(ch1);
int ch2 = in.read();
System.out.println(ch2);
}
}
我的微信号:
xiang20200106 ,欢迎大家找我聊天
— 【 THE END 】—

本公众号已经整理一套包含前端和后端的全套电子书教程,限时免费赠送,请在公众号里回复「电子书」获取!