展开全部
你好e5a48de588b63231313335323631343130323136353331333365643634,这边有一个示例代码,希望对你有所帮助。示例中的urlString,你可以下载之后看看是否跟打印信息大小一致。我这边是一致的。
p:所导入的包都是java.net下面的。
main方法中 直接调用这个函数即可。static int getNetWorkFile( ){
String urlString="https://img-blog.csdn.net/20180323154952670?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0p1c3RDbGltYmluZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70";
int length=0;
URL url;
try {
url = new URL(urlString);
HttpURLConnection urlcon=(HttpURLConnection)url.openConnection();//打开连接
//根据响应获取文件大小
length=urlcon.getContentLength();
urlcon.disconnect();//关闭连接
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(length);
return length;
}