实现代码如下:
import java.io.*;
public class ByteArrayTest {
public static void main(String[] args) {
transform(System.in, System.out);
}
public static void transform(InputStream in, OutputStream out) {
int ch = 0;
try {
while ((ch = in.read()) != -1) {
int upperCh = Character.toUpperCase((char) ch);
out.write(upperCh);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
运行结果:
里面没有实现退出,可以参考之前编写的例子:java中将输入的字符打印出来,当输入bye退出程序