日期:2014-05-20 浏览次数:20705 次
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);
}