日期:2014-05-20 浏览次数:20724 次
URL url1 = new URL("http://www.google.com/imgres? imgurl=http://a2.att.hudong.com/85/15/01300000196604122280159748057_s.jpg&imgrefurl=http://www.hudong.com/wiki/%25E7%258E%25AB%25E7%2591%25B0%25E8%258A%25B1&h=300&w=275&sz=15&tbnid=i0RGriJWfoSQOM:&tbnh=90&tbnw=83&prev=/search%3Fq%3D%25E7%258E%25AB%25E7%2591%25B0%25E8%258A%25B1%26tbm%3Disch%26tbo%3Du&zoom=1&q=%E7%8E%AB%E7%91%B0%E8%8A%B1&docid=fWy0CgEDxlwPOM&hl=en&sa=X&ei=efGET4_sMc7qmAXmp4i6Bw&ved=0CEEQ9QEwAw&dur=747"); HttpURLConnection urlConnection = (HttpURLConnection) url1.openConnection(); long len = urlConnection.getContentLength(); if(len<=0){ System.out.println( "无法获知文件大小 "); }else { System.out.println( "文件大小为 " + len/1024/1024 + "M "); }