If you are wanting to check whether a given file is of the right content type, you may want to look at URLConnection.guessContentTypeFromName() and URLConnection.guessContentTypeFromStream().
Note you can make a URL from a File.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Jun 09, 2000
you may want to look at URLConnection.guessContentTypeFromName() and URLConnection.guessContentTypeFromStream().
It seems to be a good solution but is it possible to get URLConnection somehow from request object as I must be doing this check in struts kind of framework where we only have request object to get most of the input
Joined: Jan 30, 2000
URLConnection.guessContentTypeFromName() and -Stream() are static methods, so you don't need an instance. You should be able to call these anywhere.
Joined: Oct 30, 2001
Yes, you can call them without an instance of URLConnection. My code does it: -