概念
用途
案例
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
public class StreamDemo {
public static void main(String[] args) throws IOException {
byte[] b = {'a', 'b'};
ByteArrayInputStream bai = new ByteArrayInputStream(b);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] arr = new byte[1024];
int num = 0;
while ((num = bai.read(arr)) != -1) {
bos.write(arr,0,num);
}
String s = bos.toString();
System.out.println(s);
bai.close();
bos.close();
}
}