读书人

Java IO以内存流

发布时间: 2012-09-07 10:38:15 作者: rapoo

Java IO之内存流

?

package com.chenzehe.test.io;import java.io.ByteArrayInputStream;import java.io.ByteArrayOutputStream;public class ByteArrayStreamDemo {public static void main(String[] args) {String helloworld = "helloworld";ByteArrayInputStream bis = new ByteArrayInputStream(helloworld.getBytes());ByteArrayOutputStream bos = new ByteArrayOutputStream();int temp = 0;while ((temp = bis.read()) != -1) {char c = (char) temp;bos.write(Character.toUpperCase(c));}System.out.println(bos.toString());}}

读书人网 >编程

热点推荐