Replies if the given ZIP stream contains data of the expected type.

@throws IOException if the stream cannot be read.
436649
private boolean isContentTypeIn(ZipInputStream stream) throws IOException {
		boolean isContentType = false;
		if (this.innerFile != null) {
			final String strInner = this.innerFile.toString();
			InputStream dataStream = null;
			ZipEntry zipEntry = stream.getNextEntry();
			while (zipEntry != null && dataStream == null) {
				if (strInner.equals(zipEntry.getName())) {
					dataStream = stream;
				} else {
					zipEntry = stream.getNextEntry();
				}
			}
			if (dataStream != null) {
				isContentType = isContentType(stream, zipEntry, dataStream);
			}
		} else {
			isContentType = isContentType(stream, null, null);
		}
		return isContentType;
	}
971280
@Nullable
  public static InputStream findInputStreamForResource(@Nonnull final ZipFile zipFile, @Nonnull final String resourcePath) throws IOException {
    final ZipEntry entry = zipFile.getEntry(resourcePath);

    InputStream result = null;

    if (entry != null && !entry.isDirectory()) {
      result = zipFile.getInputStream(entry);
    }

    return result;
  }
471291
public int read() throws IOException {
    if (this.bytesRead == this.length) {
      // All chunks and final additional chunk are read.
      // This means we have reached EOF.
      return -1;
    }

    try {
      // Read a chunk from given input stream when
      // it is first chunk or all bytes in chunk body is read
      if (this.streamBytesRead == 0 || this.chunkPos == this.chunkBody.length) {
        // Check if there are data available to read from given input stream.
        if (this.streamBytesRead != this.streamSize) {
          // Send all data chunks.
          int chunkSize = CHUNK_SIZE;
          if (this.streamBytesRead + chunkSize > this.streamSize) {
            chunkSize = this.streamSize - this.streamBytesRead;
          }

          if (readChunk(chunkSize) < 0) {
            return -1;
          }

          this.streamBytesRead += chunkSize;
        } else {
          // Send final additional chunk to complete chunk upload.
          byte[] chunk = new byte[0];
          createChunkBody(chunk);
        }
      }

      this.bytesRead++;
      // Value must be between 0 to 255.
      int value = this.chunkBody[this.chunkPos] & 0xFF;
      this.chunkPos++;
      return value;
    } catch (NoSuchAlgorithmException | InvalidKeyException | InsufficientDataException | InternalException e) {
      throw new IOException(e.getCause());
    }
  }
1206874
public static boolean containsAnyEntry(File zip, String[] names) {
    ZipFile zf = null;
    try {
      zf = new ZipFile(zip);
      for (int i = 0; i < names.length; i++) {
        if (zf.getEntry(names[i]) != null) {
          return true;
        }
      }
      return false;
    }
    catch (IOException e) {
      throw ZipExceptionUtil.rethrow(e);
    }
    finally {
      closeQuietly(zf);
    }
  }
129539
private void readData()
        throws IOException
    {
        while (!isClosed) {
            int code = is.read();

            switch (code) {
                case ' ':
                case '\t':
                case '\n':
                case '\r':
                    break;

                case 'C': {
                    int channel = (is.read() << 8) + is.read();

                    inputReady[channel] = true;
                    return;
                }

                case 'E': {
                    int channel = (is.read() << 8) + is.read();
                    int status = (is.read() << 8) + is.read();

                    inputReady[channel] = true;

                    return;
                }

                case -1:
                    close();
                    return;

                default:
                    // An error in the protocol.  Kill the connection.
                    close();
                    return;
            }
        }

        return;
    }
352212
private ByteArrayOutputStream getZipEntryContent(
            ZipInputStream zipStream,
            ZipEntry entry ) throws IOException {
        try (ByteArrayOutputStream content =
                new ByteArrayOutputStream()) {
            byte[] bytes = new byte[(int) entry.getSize()];
            int read;
            while ((read = zipStream.read(bytes, 0, bytes.length)) != -1) {
                content.write(bytes, 0, read);
            }
            return content;
        }
    }
1119593
private void readTrailer(final GZIPArchive.ReadEntry entry) throws IOException {

		// CRC32

		entry.crc32 = readLEInt(input);
		if (LOGGER.isTraceEnabled()) LOGGER.trace("CRC read from stream {}", Integer.valueOf(entry.crc32));

		// ISIZE

		final int iSize = readLEInt(input);
		if (entry.uncompressedSkipLength != iSize) throw new GZIPArchive.FormatException("Length mismatch between (warc) extra gzip fields uncompressed-skip-length (" + entry.uncompressedSkipLength + ") and ISIZE (" + iSize + ")");

	}
11622
private void checkReadableBytesUnsafe(int minimumReadableBytes) {
		if (readerIndex > writerIndex - minimumReadableBytes) {
			throw new IndexOutOfBoundsException(
					String.format("readerIndex(%d) + length(%d) exceeds writerIndex(%d): %s", readerIndex,
							minimumReadableBytes, writerIndex, this));
		}
	}
96167
private void checkException(DataInputStream inputStream) throws IOException {
        short retCode = inputStream.readShort();
        if(retCode != 0) {
            String error = inputStream.readUTF();
            throw mapper.getError(retCode, error);
        }
    }
331044
private byte[] readStreamCompressed(InputStream stream) throws IOException
    {
        ByteArrayOutputStream bao    = new ByteArrayOutputStream();
        GZIPOutputStream      gos    = new GZIPOutputStream(bao);
        OutputStreamWriter    output = new OutputStreamWriter(gos);
        BufferedReader        input  = new BufferedReader(new InputStreamReader(stream));
        String                line;

        while ((line = input.readLine()) != null)
        {
            output.write(line);
            output.write('\n');
        }
        input.close();
        stream.close();
        output.close();
        gos.close();
        bao.close();
        return bao.toByteArray();
    }
1271511
public static boolean isCompressed(PushbackInputStream pushbackInputStream) throws IOException {
      if (pushbackInputStream == null) {
         return false;
      }
      byte[] buffer = new byte[2];
      int read = pushbackInputStream.read(buffer);
      boolean isCompressed = false;

      if (read == 2) {
         isCompressed = ((buffer[0] == (byte) (GZIPInputStream.GZIP_MAGIC)) && (buffer[1] == (byte) (GZIPInputStream.GZIP_MAGIC >> 8)));
      }

      if (read != -1) {
         pushbackInputStream.unread(buffer, 0, read);
      }

      return isCompressed;
   }
742035
public boolean isConsitentWithIndex() throws IOException {
        byte[] b = new byte[keySize];
        long offset = 0;
        int maxChunk = getChunkIndex(getFilledUpFromContentStart());
        boolean isConsistent = true;
        for (int i = 1; i <= maxChunk; i++) {
            offset = i * getChunkSize() - elementSize;
            read(offset, ByteBuffer.wrap(b));
            if (KeyUtils.compareKey(getIndex().maxKeyPerChunk[i - 1], b) != 0) {
                logger.error("Index is not consistent to data. Expected {}, but found {}.",
                        Arrays.toString(getIndex().maxKeyPerChunk[i - 1]), Arrays.toString(b));
                isConsistent = false;
            }
        }
        return isConsistent;
    }
583321
public boolean next() throws IOException {
		boolean hasNext = true;
		try {
			oldId = stream.readInt();
			oldText = stream.readUTFAsArray();
		} catch (EOFException e) {
			hasNext = false;
		}
		return hasNext;
	}
138145
private boolean readNextChunkFromFile() throws IOException {
        if (readOffset >= filledUpToWhenStarted || readOffset < 0) {
            return false;
        }

        bufferedReader.clear();
        dataFile.read(readOffset, bufferedReader);
        bufferedReader.position(0);
        if (bufferedReader.limit() > 0) {
            readOffset += bufferedReader.limit();
            while (bufferedReader.remaining() > 0) {
                byte[] dst = new byte[elementSize];
                bufferedReader.get(dst);
                pendingElements.add(dst);
            }
        }
        return true;
    }
1364019
public void readFrom (ObjectInputStream in)
        throws IOException
    {
        int length = in.readShort();
        _mask = new byte[length];
        in.read(_mask);
    }
544710
def __isValidZIP(self, suffix):
        """"""
        if suffix and isinstance(suffix, string_types):
            if suffix.endswith(".zip"):
                return True
        return False
731577
public static boolean isNext(final Buffer buffer, final byte b) throws IOException {
        if (buffer.hasReadableBytes()) {
            final byte actual = buffer.peekByte();
            return actual == b;
        }

        return false;
    }