JAVA獲取網絡文件的大小

URL url = new URL("http://img.my.csdn.net/uploads/201403/28/1395984494_5324.png");
			URLConnection uc = url.openConnection();
	        String fileName = uc.getHeaderField(6);
	        fileName = URLDecoder.decode(fileName.substring(fileName.indexOf("filename=")+9),"UTF-8");
	        System.out.println("文件名爲:"+fileName);
	        System.out.println("文件大小:"+(uc.getContentLength()/1024)+"KB");
相關文章
相關標籤/搜索