Пример #1
0
  private ByteBuffer peekNextChunk() throws IOException {

    if (nextChunk == null) {
      ByteBuffer buffer = ByteBuffer.allocate(chunkSize);
      long length = body.read(buffer);
      if (length < 0) {
        // Negative means this is finished
        buffer.flip();
        nextChunk = buffer;
        endOfInput = true;
      } else if (length == 0) {
        // Zero means we didn't get anything this time, but may get next time
        buffer.flip();
        nextChunk = null;
      } else {
        buffer.flip();
        nextChunk = buffer;
      }
    }
    return nextChunk;
  }
Пример #2
0
 public void close() throws Exception {
   body.close();
 }