JavaIO之ByteArrayStream(一)

来源:互联网 发布:mac pro type c 编辑:程序博客网 时间:2024/06/06 16:51
package three.day.io;


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Arrays;


public class ByteArrayStreamTs {


public static void main(String[] args) {
String msg = "ishfsdhfiwshfiewhfihwifewhifew";
ByteArrayInputStream bis = new ByteArrayInputStream(msg.getBytes());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
transform(bis,bos);
System.out.println(Arrays.toString(bos.toByteArray()));
System.out.println(new String(bos.toByteArray()));
}


private static void transform(ByteArrayInputStream bis,
ByteArrayOutputStream bos) {
int c = -1;
while((c=bis.read())!=-1){
bos.write((int)Character.toUpperCase((char)c));
}
}


}
原创粉丝点击