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 {
@Test
public 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();
}
}
}
}