仰延Elliot 2022-10-12 14:40 采纳率: 0%
浏览 65

java获取inputstream 没读完就 返回-1

java获取inputstream 没读完就 返回-1

while (cumlativeLen <= dataSize && (len = inputStream.read(buffer)) != -1) {
            mergeRAFile.write(buffer, 0, len);
            //计算累计下载的长度
            cumlativeLen += len;
            cumlativeLenKb = cumlativeLen / ONE_Kb;
            writingPosition = start + cumlativeLen;
            actualWritingPosition = actualStart + cumlativeLen;
            publishMsg(cumlativeLen, cumlativeLenKb);
            if (start + cumlativeLen >= end) {// 下载完成:程优化之后,新的End作为下载完成的标志
                isDownloadCompleted = true;
                break;
            }
            if (isStopWrite) { // 停止写入
                if (null != threadCallback) {
                    LogUtils.debugNoLine(TAG, "Stop " + config.getFileName() + " ThreadId:" + config.getId());
                    threadCallback.onStopWrite(config.getId(), start, cacheingSize, end, isDownloadCompleted);
                }
                break;
            }

        }
  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-10-12 15:17
    关注
    评论

报告相同问题?

问题事件

  • 创建了问题 10月12日