News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

URLConnection getContentType Example

Started by VelMurugan, Dec 20, 2008, 10:25 PM

Previous topic - Next topic

VelMurugan

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

Source : codingdiary