Java URLConnection .guessContentTypeFromName (String fname)
Syntax
URLConnection.guessContentTypeFromName(String fname) has the following syntax.
public static String guessContentTypeFromName(String fname)
Example
In the following code shows how to use URLConnection.guessContentTypeFromName(String fname) method.
/*from w w w.j ava2s. c o m*/
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
public class Main{
public static void main(String args[]) throws Exception {
URL url = new URL("http://www.google.com");
URLConnection httpCon = (URLConnection) url.openConnection();
System.out.println(URLConnection.guessContentTypeFromName("abc.htm"));
}
}
The code above generates the following result.