0

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.

gchan
  • 27
  • 2
  • 9
  • 2
    Generally speaking, you can use a content-type to guess what a filetype is. However, you can never be sure. Not the least because content-types often lie. – Aurand Sep 20 '13 at 20:00
  • 1
    I think that's a duplicate of http://stackoverflow.com/questions/51438/getting-a-files-mime-type-in-java – Archer Sep 20 '13 at 20:06

1 Answers1

1

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"));
}
EmpathicSage
  • 1,265
  • 8
  • 11
  • Thanks. I've been switching around between Perl, PHP, Javascript, Java, Bash, and Objective-C so much that I didn't catch it. I appreciate the feedback. – EmpathicSage Sep 24 '13 at 00:10