62,614
社区成员
发帖
与我相关
我的任务
分享
import java.io.IOException;
import java.net.URL;
class test {
public static void main( String[ ] args ) throws Exception {
test t=new test();
t.getLength("http://224.cachefile30.rayfile.com/e5cb/zh-cn/download/3ef8e0cb98a945dec0f96c0101cd4bc8/preview.mp3");
System.out.println();
t.getLength("http://www.python.org/ftp/python/2.5/python-2.5.msi");
System.out.println();
}
static void getLength(String str)throws Exception {
URL url = new URL(str);
int size = url.openConnection( ).getContentLength( );
System.out.printf( "%s is only %.1f MB in size. ", url, size / Math.pow( 2, 20 ) );
}
}
http://224.cachefile30.rayfile.com/e5cb/zh-cn/download/3ef8e0cb98a945dec0f96c0101cd4bc8/preview.mp3 is only -0.0 MB in size.
http://www.python.org/ftp/python/2.5/python-2.5.msi is only 10.2 MB in size.
"http://224.cachefile19.rayfile.com/47a7/zh-cn/download/5eaf73476d825e64ea261abd79d044ea/preview.wma"