In Java, it's possible determine the size of a web page before download?
问题 I want determine the size of a web page, and so, if it is greater than a number (eg.:5MB), I will download it or not. Can I have this information? 回答1: You can do a decent approximation with: HttpURLConnection content = (HttpURLConnection) new URL("www.example.com").openConnection(); System.out.println(content.getContentLength()); However, this will only tell you the length of the specific resource you're requesting (e.g. the HTML at the base of the URL). You will also need to go through the