简体   繁体   中英

Is it possible to use the content-type of a file to determine its filetype in Java?

If so, how can I do that?

I'm trying to write a method that takes a content-type and returns whether it is a JSON file or not.

Here is a function which takes in a content-type string from an HTTP request and returns TRUE if the content-type was a JSON type or FALSE if it wasn't.

public static boolean isJsonContentType(String contentType) {
    return (contentType.equals("application/json"));
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM