code: protected MimeType guessMimeType(byte[] data)
              throws IOException, IllegalArgumentException, NullPointerException {
          String mimeTypeString;
          InputStream is = null;
          try {
              is = new ByteArrayInputStream(data);
              mimeTypeString = URLConnection.guessContentTypeFromStream(is);
          } finally {
              if (is != null) {
                  is.close();
              }
          }
          return MimeType.valueOfMimeType(mimeTypeString);
      }
docs: Guesses the {@link MimeType} of the given {@code byte[]} contents.
  
  @param data The image data.
  @return The matching {@link MimeType}.
  @see URLConnection#guessContentTypeFromStream(InputStream)
  @throws IOException If something goes wrong with the data stream.
  @throws IllegalArgumentException If the guessing resulted in an
  unsupported MIME-Type.
  @throws NullPointerException If the guessing did not find any matching
  MIME-Type.