如题,今天老师给我出的题,不管是字符流还是字节流均可 欢迎大家讨论!

解决方案 »

  1.   

    for example
    String s = "1234567890abcdefg";
    byte[] b = s.getBytes();
    ByteArrayInputStream bis = new ByteArrayInputStream(b); //输入流
    ByteArrayOutputStream bos = new ByteArrayOutputStream(); //输出流
    bos.write(b, 0, b.length); //写到输出流
     
      

  2.   

        ByteArrayInputStream bis = new ByteArrayInputStream("abcdef".getBytes()); ByteArrayOutputStream bos = new ByteArrayOutputStream(); int ch = 0;
    while ((ch = bis.read()) != -1) {
    bos.write(ch);
    }