for example String s = "1234567890abcdefg"; byte[] b = s.getBytes(); ByteArrayInputStream bis = new ByteArrayInputStream(b); //输入流 ByteArrayOutputStream bos = new ByteArrayOutputStream(); //输出流 bos.write(b, 0, b.length); //写到输出流
ByteArrayInputStream bis = new ByteArrayInputStream("abcdef".getBytes()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); int ch = 0; while ((ch = bis.read()) != -1) { bos.write(ch); }
String s = "1234567890abcdefg";
byte[] b = s.getBytes();
ByteArrayInputStream bis = new ByteArrayInputStream(b); //输入流
ByteArrayOutputStream bos = new ByteArrayOutputStream(); //输出流
bos.write(b, 0, b.length); //写到输出流
while ((ch = bis.read()) != -1) {
bos.write(ch);
}