java.se.io.9.字节数组节点流

来源:互联网 发布:淘宝怎样退货退款申请 编辑:程序博客网 时间:2024/06/06 16:50
package com.knock.io;import java.io.BufferedInputStream;import java.io.ByteArrayInputStream;import java.io.IOException;import org.junit.Test;/** * @date 160802pm * 字节数组节点流,可以与数组之间交互 * */public class KjByteArray {@Testpublic void test(){String str ="i m shadow u r light";byte[] arr = str.getBytes();BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(arr));byte[] car = new byte[1024];int len;try {while(-1!=(len=(bis.read(car)))){String str2 = new String(car,0,len);System.out.println(str2);}} catch (IOException e) {e.printStackTrace();}finally{try {if(null!=bis){bis.close();}} catch (IOException e) {e.printStackTrace();}}}}

0 0
原创粉丝点击