InputStream bi = new BufferedInputStream(new ByteArrayInputStream(c));
int len = 0;
byte[] flush = new byte[1024];
String s = "";
while (-1 != (len = bi.read(flush))) {
s += new String(flush, 0, len);
}
System.out.println(s);
bi.close();
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write(c, 0, c.length);
byte[] dest;
dest = os.toByteArray();
return dest;
bi.close();
package cn.hxh.io.other;
import java.io.*;
public class ByteArrayDemo01 {
public static void main(String[] args) throws IOException {
read(write());
}
public static void read(byte[] c) throws IOException {
InputStream bi = new BufferedInputStream(new ByteArrayInputStream(c));
int len = 0;
byte[] flush = new byte[1024];
String s = "";
while (-1 != (len = bi.read(flush))) {
s += new String(flush, 0, len);
}
System.out.println(s);
}
public static byte[] write() throws IOException {
String str = "你好你好";
byte[] c = str.getBytes();
ByteArrayOutputStream os = new ByteArrayOutputStream();
os.write(c, 0, c.length);
byte[] dest;
dest = os.toByteArray();
return dest;
}
}