public class ClientWithResponseHandler {
public static void main(String[] args) {
test("http://www.google.com");
}
public static String test(String url) {
String result = "";
try {
URL httpurl = new URL(url);
HttpURLConnection httpConn = (HttpURLConnection) httpurl.openConnection();
InputStream i=httpConn.getInputStream();
int l=0;
while(i.read()!=-1){
l++;
}
System.out.println(l);
i.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}
get web url content length
最新推荐文章于 2020-05-20 08:35:43 发布