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;
            }

        }