Java 实例 - 获取远程文件大小
Java 教程
· 2019-02-11 20:42:42
以下实例演示了如何获取远程文件的大小:
Main.java 文件
import java.net.URL;
import java.net.URLConnection;
public class Main {
public static void main(String[] args) throws Exception {
int size;
URL url = new URL("http://www.codercto.com/wp-content/themes/codercto/assets/img/newlogo.png");
URLConnection conn = url.openConnection();
size = conn.getContentLength();
if (size < 0)
System.out.println("无法获取文件大小。");
else
System.out.println("文件大小为:" + size + " bytes");
conn.getInputStream().close();
}
}
以上代码运行输出结果为:
文件大小为:4261 bytes
点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html
Paradigms of Artificial Intelligence Programming
Peter Norvig / Morgan Kaufmann / 1991-10-01 / USD 77.95
Paradigms of AI Programming is the first text to teach advanced Common Lisp techniques in the context of building major AI systems. By reconstructing authentic, complex AI programs using state-of-the-......一起来看看 《Paradigms of Artificial Intelligence Programming》 这本书的介绍吧!