URLConnection getContent Example

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


URLConnection class getContent example. public Object getContent(Class[] classes) throws IOException Retrieves the contents of this URL connection.

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

import java.io.*;
import java.net.*;

public class GetContent1 {

    public static void main(String args[]) throws Exception {

        URL url = new URL("http://localhost:8080/net/listnets.jsp");
        URLConnection connection = url.openConnection();

        Class type[] {String.class, Reader.class, URLConnection.class};
        Object obj = connection.getContent(type);

        if (obj == null) {
         throw new Exception("None of requested type were abailable");
        }
    }
}

Output
Exception in thread "main" java.lang.Exception: None of requested type were abailable
        at GetContent1.main(GetContent1.java:23)

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

HOME | COPYRIGHT | CONTACT US