class TgzParser {

  public InputStream getChartFromInputStream(final InputStream is) throws IOException {
    try (GzipCompressorInputStream gzis = new GzipCompressorInputStream(is)) {
      try (TarArchiveInputStream tais = new TarArchiveInputStream(gzis)) {
        ArchiveEntry currentEntry;
        while ((currentEntry = tais.getNextEntry()) != null) {
          if (currentEntry.getName().endsWith(CHART_NAME)) {
            byte[] buf = new byte[(int) currentEntry.getSize()];
            tais.read(buf, 0, buf.length);
            return new ByteArrayInputStream(buf);
          }
        }
      }
    }
    throw new IllegalArgumentException(String.format("%s not found", CHART_NAME));
  }

}