URLConnection getContent Example
URLConnection class getContent example. This example shows you how to use getContent method.
URLConnection class getContent example. ublic Object getContent() throws IOException Retrieves the contents of this URL connection. This method first determines the content type of the object by calling the getContentType method.
Here is the code
/*
* @ # GetContent.java
* A class repersenting use to getContent
* method of URLConnection class in java.net package
* version 23 June 2008
* author Rose India
*/
import java.net.*;
public class GetContent {
public static void main(String args[]) throws Exception {
URL url = new URL("http://localhost:8080/net/listnets.jsp");
URLConnection connection = url.openConnection();
System.out.println("Content "+connection.getContent());
}
} |
Output
| Content sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@19b49e6 |
|