对ByteArrayInputStream/ByteArrayOutputStream类的应用里的transform函数的复用
2016-04-01 10:45
501 查看
实现代码如下:
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退出程序
相关文章推荐
- 对PipedOutputStream/PipedInputStream类的应用
- 对ByteArrayInputStream/ByteArrayOutputStream类的应用
- php冒泡排序
- Zend Studio使用技巧两则
- 【PHPStorm使用手册】php interpreter is not configured
- 对FileOutputStream/FileInputStream的应用
- Github上的PHP资源汇总大全
- PHP数学运算与数据处理实例分析
- php的PDO
- php函数之func_get_args()、func_get_arg()与func_num_args()
- 【PHPStorm使用手册】如何设置字体大小?
- PHP数学运算函数大汇总(经典值得收藏)
- yii2-user
- Doctrine学习笔记(实体ManyToMany) —— 4
- 最简单的FTP客户端、服务器端
- php 配置文件
- php 配置文件
- php 配置文件
- php多线程抓取网页
- 综合归纳:PHP中empty()、is_null()和isset()的区别