解决方案 »

  1.   

    看起来代码没有什么问题,
     nReadLen = dis.read(buffer, nIdx, nTotalLen - nIdx); 检查一下是否是下标有问题。 public static byte[] readInputStream(InputStream ins) {
    if (ins == null) {
    return null;
    }
    BufferedInputStream bis = new BufferedInputStream(ins);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try {
    byte[] buffer = new byte[128];
    int n = -1;
    while ((n = bis.read(buffer)) != -1) {
    bos.write(buffer, 0, n);
    }
    } catch (IOException e) {
    e.printStackTrace();
    return null;
    } finally {
    if (bis != null) {
    try {
    bis.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    return bos.toByteArray();
    }
    读完了所有的数据流以后 再进行byte数组操作。
    建议把网络操作放到线程里面。
      

  2.   

    read是阻塞读,一定要放在线程里面
      

  3.   

    read阻塞了,你从一个跳转过去出问题,要么就是权限问题或者什么东西忘记关了
      

  4.   

     while (nIdx < nTotalLen) 这里一直卡死了吧?转头又卡在read上了,没跑下去