Code example for InputStream

Methods: read

0
    input = checksumIn;       
   
    // Are map-outputs compressed? 
    if (codec != null) {
      decompressor.reset();
      input = codec.createInputStream(input, decompressor);
    } 
   
    try { 
      IOUtils.readFully(input, memory, 0, memory.length);
      metrics.inputBytes(memory.length);
      reporter.progress();
      LOG.info("Read " + memory.length + " bytes from map-output for " +
                getMapId()); 
 
      /** 
       * We've gotten the amount of data we were expecting. Verify the 
       * decompressor has nothing more to offer. This action also forces the 
       * decompressor to read any trailing bytes that weren't critical 
       * for decompression, which is necessary to keep the stream 
       * in sync. 
       */ 
      if (input.read() >= 0 ) {
        throw new IOException("Unexpected extra bytes from input stream for " +
                               getMapId()); 
      } 
 
    } catch (IOException ioe) {      
      // Close the streams 
      IOUtils.cleanup(LOG, input);
 
      // Re-throw 
      throw ioe;
    } finally { 
      CodecPool.returnDecompressor(decompressor);
Contextual code suggestions in your IDE  Get Codota for Java