黑马程序员技术交流社区

标题: 求大神讲解代码!! [打印本页]

作者: 史柯    时间: 2015-8-26 16:17
标题: 求大神讲解代码!!
  1. public class ByteArrayStreamDemo {
  2.         public static void main(String[] args) throws IOException {
  3.                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
  4.                 for (int x = 0; x < 10; x++) {
  5.                         baos.write(("hello" + x).getBytes());
  6.                 }
  7.                 byte[] bys = baos.toByteArray();

  8.                 ByteArrayInputStream bais = new ByteArrayInputStream(bys);

  9.                 int by = 0;
  10.                 while ((by = bais.read()) != -1) {
  11.                         System.out.print((char) by);
  12.                 }
  13.         }
  14. }
复制代码





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2