athrunwang

          紀(jì)元
          數(shù)據(jù)加載中……
          byte[]和InputStream的相互轉(zhuǎn)換
          import java.io.ByteArrayInputStream;
          import java.io.ByteArrayOutputStream;
          import java.io.IOException;
          import java.io.InputStream;
          public class ByteToInputStream {
          public static final InputStream byte2Input(byte[] buf) {
          return new ByteArrayInputStream(buf);
          }
          public static final byte[] input2byte(InputStream inStream)
          throws IOException {
          ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
          byte[] buff = new byte[100];
          int rc = 0;
          while ((rc = inStream.read(buff, 0, 100)) > 0) {
          swapStream.write(buff, 0, rc);
          }
          byte[] in2b = swapStream.toByteArray();
          return in2b;
          }
          }

          posted on 2013-03-05 14:13 AthrunWang 閱讀(232) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 上犹县| 鄂尔多斯市| 宣恩县| 墨竹工卡县| 海淀区| 遂平县| 兰州市| 那曲县| 张家口市| 秭归县| 济源市| 四会市| 荔浦县| 达州市| 措美县| 嘉峪关市| 阿巴嘎旗| 嘉荫县| 沙田区| 思南县| 连江县| 东山县| 清徐县| 富民县| 长垣县| 容城县| 阿克陶县| 堆龙德庆县| 从化市| 乌审旗| 崇左市| 上虞市| 贡觉县| 家居| 郸城县| 长寿区| 囊谦县| 廊坊市| 安达市| 蚌埠市| 南陵县|