可以- import java.io.*;
- public class ByteArrayTest {
- public static void main(String[] args) {
- byte[] ch = {'h','e','l','l','o'};
- ByteArrayInputStream bin = new ByteArrayInputStream(ch);//实例化输入流
- ByteArrayOutputStream bout = new ByteArrayOutputStream();//实例化输出流
- int temp = 0;
- while((temp = bin.read())!=-1){//直到末尾
- bout.write(temp);
- }
- String result = bout.toString();//拿出缓存中的数据
- System.out.print(result);
- }
- }
复制代码 |