HttpURLConnection uc = null ;
URLPath = "";
URL url = new URL(URLPath);
uc = (HttpURLConnection) url.openConnection();
uc.setReadTimeout(10000);
uc.connect();
FileOutputStream fos = new FileOutputStream(savePath);
InputStream in = uc.getInputStream();
byte[] buffer = new byte[1024];
int Length = 0;
long FinishedLenth = 0;
while((Length = in.read(buffer)) > 0) {
    FinishedLenth = FinishedLenth + Length;
    fos.write(buffer, 0, Length);
}
uc.disconnect();
in.close();
fos.close(); 
これは私の関数コードで、ネットワークが切断されている場合、
コードは例外になります。
そして例外にリトライ機能を書きます。
userValue =0、再試行を意味し、1 はキャンセルを意味します。  
int userValue = gm.GetIt("Error");
if(userValue == 0){
 gp.interrupt();
 uc.disconnect();
 downloadFile(local,nas,ip,id,pw,fileId,index);
}
else{
 conf.downloadState.get(index).setpercent("fail");
 return false;
}
こんにちは、困っています。
私はコードを書き、機能はダウンロードです。
また、ネットワークが切断された場合、ユーザーは再試行またはキャンセルを選択できます。
しかし、エラーメッセージが表示されます。  
java.net.SocketTimeoutException: Read timed out  
    at java.net.SocketInputStream.socketRead0(Native Method)  
    at java.net.SocketInputStream.read(Unknown Source)  
    at java.io.BufferedInputStream.fill(Unknown Source)  
    at java.io.BufferedInputStream.read1(Unknown Source)  
    at java.io.BufferedInputStream.read(Unknown Source)  
    at sun.net.www.MeteredStream.read(Unknown Source)  
    at java.io.FilterInputStream.read(Unknown Source)  
    at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)  
    at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)  
    at Download_File.downloadFile(Download_File.java:54)  
    at downloadFileFunctionThread.run(downloadFileFunctionThread.java:113)  
そして54行目はwhile(......)です。