Java Mime Type Get extractMimeType(byte[] imageData)

Here you can find the source of extractMimeType(byte[] imageData)

Description

extract Mime Type

License

Open Source License

Declaration

public static String extractMimeType(byte[] imageData) throws IOException 

Method Source Code

//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.io.*;

import java.net.URLConnection;

public class Main {
    public static String extractMimeType(byte[] imageData) throws IOException {
        try (ByteArrayInputStream input = new ByteArrayInputStream(imageData)) {
            String contentType = URLConnection.guessContentTypeFromStream(input);
            return contentType != null ? contentType : "image/xyz";
        }//  www  . j a  va  2 s.c  om
    }
}

Related

  1. getExactMimeType(String fileName)
  2. getMimeType(File file)
  3. getMimeType(String file)
  4. getMimeType(String fileName)