URLConnection getContentLength Example
URLConnection class getContentLength example. This example shows you how to use getContentLength method.
URLConnection class getContentLength example. public int getContentLength() Returns the value of the content-length header field.
Here is the code
/*
* @ # GetContentLength.java
* A class repersenting use to GetContentLength
* method of URLConnection class in java.net package
* version 23 June 2008
* author Rose India
*/
import java.net.*;
public class GetContentLength {
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-length " +
connection.getContentLength());
}
} |
|