athrunwang

          紀元
          數(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)航:
           
          主站蜘蛛池模板: 五常市| 泰顺县| 镇远县| 盐边县| 凯里市| 彩票| 玉屏| 枞阳县| 新蔡县| 岐山县| 平定县| 惠来县| 淮阳县| 兴业县| 临高县| 竹溪县| 余干县| 招远市| 厦门市| 鄂伦春自治旗| 胶州市| 霞浦县| 手游| 利川市| 灵寿县| 衡阳县| 安吉县| 泸州市| 根河市| 正阳县| 湟中县| 沽源县| 平原县| 噶尔县| 准格尔旗| 平阴县| 封丘县| 衡山县| 资中县| 崇州市| 清涧县|