如题,今天老师给我出的题,不管是字符流还是字节流均可 欢迎大家讨论!
------解决方案--------------------------------------------------------
for example
- Java code
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);
}