URLConnection getContentType Example

URLConnection class getContentType example. This example shows you how to use getContentType method.


URLConnection class getContentType example. public String getContentType() Returns the value of the content-type header field.

Here is the code
/*
 * @ # GetContentType.java
 * A class repersenting use to GetContentType 
 * method of URLConnection class in java.net package
 * version 23 June 2008
 * author Rose India 
 */

import java.net.*;

public class GetContentType {

    public static void main(String args[]) throws Exception {
        URL url = new URL("http://localhost:8080/net/index.jsp");
        URLConnection connection = url.openConnection();

        System.out.println("content-type " +
                connection.getContentType());
    }
}

Output
content-type text/html

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US