日期:2014-05-20 浏览次数:20700 次
byte[] b1 = {1,2,3,4}; byte[] b2 = {5,6,7,8}; ByteArrayOutputStream bos = new ByteArrayOutputStream(); bos.write(b1, 0, b1.length); bos.write(b2, 0, b2.length); byte[] b3 = bos.toByteArray(); //相当于b2接到b1后面,得到一个新的byte数组b3 ByteArrayInputStream bis = new ByteArrayInputStream(b3); int n = 0; while ((n=bis.read()) != -1) { //从字节流中读入字节并输出 System.out.println(n); }