docs: private static byte[] readCatalog(String catalogUrl) throws IOException
      {
          assert (catalogUrl != null);
  
          final int MAX_CATALOG_SIZE = 40 * 1024 * 1024; // 40mb
  
          InputStream fin = null;
          try {
              URL url = new URL(catalogUrl);
              fin = url.openStream();
          } catch (MalformedURLException ex) {
              // Invalid URL. Try as a file.
              fin = new FileInputStream(catalogUrl);
          }
          byte[] buffer = new byte[MAX_CATALOG_SIZE];
          int readBytes = 0;
          int totalBytes = 0;
          try {
              while (readBytes >= 0) {
                  totalBytes += readBytes;
                  readBytes = fin.read(buffer, totalBytes, buffer.length - totalBytes - 1);
              }
          } finally {
              fin.close();
          }
  
          return Arrays.copyOf(buffer, totalBytes);
      }