📄 downloadutil.java
字号:
package com;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2009</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
import java.net.HttpURLConnection;
import java.net.URL;
public class DownloadUtil {
public int getFileLength(String url) throws Exception{
int length = 0;
URL downladURL = new URL(url);
HttpURLConnection con = (HttpURLConnection) downladURL.openConnection();
int stateCode = con.getResponseCode();
if (stateCode != 200) {
length = -1;
}
int size = con.getContentLength();
con.disconnect();
length = size;
return length;
}
public boolean isFinished(boolean[] isStop){
boolean isFinished = false;
for(int i=0;i<isStop.length;){
boolean flag = isStop[i];
if(!flag){
try{
Thread.sleep(3000);
}catch(Exception e){
e.printStackTrace();
}
isFinished = false;
}else{
isFinished = true;
i++;
}
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -