字节内存流:
package com.qyl.test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import org.junit.Test;
public class ByteArrayOutputStreamTest{
@Test
public void test1() throws Exception {
ByteArrayOutputStream by = new ByteArrayOutputStream();
String str = "哈哈哈";
byte[] bt = str.getBytes();
by.write(bt,0,bt.length);
byte[] buf = by.toByteArray();
ByteArrayInputStream input = new ByteArrayInputStream(buf);
byte[] bytes = new byte[10];
int len;
while ((len=input.read(bytes))!=-1) {
System.out.println(new String(bytes, 0, len));
}
}
}