This method returns the next chunk of the wrapped InputStream.
<p/>
Throws a runtime exception if next() is called before previous stream
was fully read.

@return next chunk as InputStream
433946
public ChunkInputStream next() {
        throwIfChunkNotFullyRead();

        // Before return next chunk, catalog current chunk in manifest.
        addEntry();

        long chunkSize = calculateNextChunkSize();
        String chunkId = manifest.nextChunkId();

        InputStream buffIS = new BufferedInputStream(largeStream, BUFFER_SIZE);
        return currentChunk = new ChunkInputStream(chunkId,
                                                   buffIS,
                                                   chunkSize,
                                                   preserveChunkMD5s);
    }
156833
public synchronized InputStream getInputStream() throws IOException {
        if (!connected) {
            connect();
        }

        // Nothing to return
        if (responseCode == HTTP_NOT_FOUND) {
            throw new FileNotFoundException(url.toString());
        }
        int length;

        if (inputStream == null) {
            return null;
        }

        // "De-chunk" the output stream
        else if ("chunked".equalsIgnoreCase(getHeaderField("Transfer-Encoding"))) {
            if (!(inputStream instanceof ChunkedInputStream)) {
                inputStream = new ChunkedInputStream(inputStream);
            }
        }

        // Make sure we don't wait forever, if the content-length is known
        else if ((length = getHeaderFieldInt("Content-Length", -1)) >= 0) {
            if (!(inputStream instanceof FixedLengthInputStream)) {
                inputStream = new FixedLengthInputStream(inputStream, length);
            }
        }
        return inputStream;
    }
1084269
private void nextChunk() throws IOException {
        if (state == CHUNK_INVALID) {
            throw new MalformedChunkCodingException("Corrupt data stream");
        }
        try {
            chunkSize = getChunkSize();
            if (chunkSize < 0L) {
                throw new MalformedChunkCodingException("Negative chunk size");
            }
            state = CHUNK_DATA;
            pos = 0L;
            if (chunkSize == 0L) {
                eof = true;
                parseTrailerHeaders();
            }
        } catch (MalformedChunkCodingException ex) {
            state = CHUNK_INVALID;
            throw ex;
        }
    }
562431
protected synchronized InputStream getInputStream() throws IOException {
        if (isClosedOrPending()) {
            throw new IOException("Socket Closed");
        }
        if (shut_rd) {
            throw new IOException("Socket input is shutdown");
        }
        if (socketInputStream == null) {
            socketInputStream = new SocketInputStream(this);
        }
        return socketInputStream;
    }
1227611
private int nextByte() throws IOException {
        int result = 0;
        if (!endOfStream) {
            result = read();
            if (result == -1) {
                endOfStream = true;
            }
        }
        return endOfStream ? 0 : result;
    }
124226
private boolean setUpNextChunk() throws IOException {
        byte[] chunkData = new byte[DEFAULT_CHUNK_SIZE];
        int chunkSizeInBytes = 0;
        while (chunkSizeInBytes < DEFAULT_CHUNK_SIZE) {
            /** Read from the buffer of the decoded stream */
            if (null != decodedStreamBuffer
                    && decodedStreamBuffer.hasNext()) {
                chunkData[chunkSizeInBytes++] = decodedStreamBuffer.next();
            }
            /** Read from the wrapped stream */
            else {
                int bytesToRead = DEFAULT_CHUNK_SIZE - chunkSizeInBytes;
                int count = is.read(chunkData, chunkSizeInBytes, bytesToRead);
                if (count != -1) {
                    if (null != decodedStreamBuffer)
                        decodedStreamBuffer.buffer(chunkData, chunkSizeInBytes, count);
                    chunkSizeInBytes += count;
                }
                else
                    break;
            }
        }
        if (chunkSizeInBytes == 0){
            byte[] signedFinalChunk = createSignedChunk(FINAL_CHUNK);
            currentChunkIterator = new ChunkContentIterator(signedFinalChunk);
            return true;
        }
        else {
            if (chunkSizeInBytes < chunkData.length) {
                chunkData = Arrays.copyOf(chunkData, chunkSizeInBytes);
            }
            byte[] signedChunkContent = createSignedChunk(chunkData);
            currentChunkIterator = new ChunkContentIterator(signedChunkContent);
            return false;
        }
    }
76063
public JsonElement next() throws JsonParseException {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    
    try {
      return Streams.parse(parser);
    } catch (StackOverflowError e) {
      throw new JsonParseException("Failed parsing JSON source to Json", e);
    } catch (OutOfMemoryError e) {
      throw new JsonParseException("Failed parsing JSON source to Json", e);
    } catch (JsonParseException e) {
      throw e.getCause() instanceof EOFException ? new NoSuchElementException() : e;
    }
  }
984745
public String getContent() {
    	StringBuffer buf = new StringBuffer();
    	for (Iterator i = getChunks().iterator(); i.hasNext(); ) {
    		buf.append(i.next().toString());
    	}
    	return buf.toString();
    }
781851
protected Content getNextFile() throws IOException {
        JarEntry entry;
        if ((entry = jis.getNextJarEntry()) != null) {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            byte[] data = new byte[BUFFER];
            int size;
            while ((size = jis.read(data, 0, data.length)) != -1) {
                bos.write(data, 0, size);
            }
            Content file = new Content(entry.getName(), bos.toByteArray());
            bos.close();
            return file;
        }
        return null;
    }
196310
public int read() throws IOException {
    if (chunk == null || pos + 1 == chunk.length) {
      if (!fetchChunk()) {
        return -1;
      }
    }
    return chunk[pos++] & 0xff;
  }
625634
public Object next()
  {
    if(TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "next");
    
    StreamSet sourceStreamSet = (StreamSet)super.next();
    SIMPPtoPOutboundTransmitControllable sourceStreamSetControl = 
      (SIMPPtoPOutboundTransmitControllable)sourceStreamSet.getControlAdapter();
    if(sourceStreamSetControl != null)
    {
      ((SourceStreamSetControl)sourceStreamSetControl).setSourceStreamManager(sourceStreamMgr);
    }
    
    if(TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "next", sourceStreamSetControl);
    return sourceStreamSetControl;
  }
603734
private static State next(final InputStream stream, final State state,
        final ByteArrayOutputStream line) throws IOException {
        final int next = stream.read();
        if (next == -1) {
            throw new IOException("chunked stream ended unexpectedly");
        }
        final State result;
        switch (state) {
            case NORMAL:
                result = nextNormal(state, line, next);
                break;
            case R:
                if (next == '\n') {
                    result = State.END;
                } else {
                    throw new IOException(
                        String.format(
                            "%s%s",
                            "Protocol violation: Unexpected",
                            " single newline character in chunk size"
                        )
                    );
                }
                break;
            case QUOTED_STRING:
                result = nextQuoted(stream, state, line, next);
                break;
            default:
                throw new IllegalStateException("Bad state");
        }
        return result;
    }
476497
public alluxio.grpc.Chunk getChunk() {
    return chunk_ == null ? alluxio.grpc.Chunk.getDefaultInstance() : chunk_;
  }
431641
public String next() throws IOException {
        if (done) {
            return null;
        }
        for (;;) {
            if (line == null) {
                line = reader.readLineSkippingComments();
                if (line == null) {
                    done = true;
                    return null;
                }
                pos = 0;
            }
            buf.setLength(0);
            lastpos = pos;
            pos = nextToken(pos);
            if (pos < 0) {
                line = null;
                continue;
            }
            return buf.toString();
        }
    }
342769
InputStream getInputStream() {
    InputStream result = (InputStream) streams.get();
    return ((result == null) ? defaultInputStream : result);
  }
1206947
final void nextStream() throws IOException {
        if (in != null) {
            in.close();
        }

        if (e.hasMoreElements()) {
            in = (InputStream) e.nextElement();
            if (in == null)
                throw new NullPointerException();
        }
        else in = null;

    }
207918
@Override
	public T next() {
		if (!hasNext()) {
			throw new NoSuchElementException(toString() + " ended");
		}

		current = iterator.next();

		return current();
	}