자바 애플리케이션에서 정상적으로 작동하지만 다운로드를 다시 시작하기위한 코드가 Android에서 제대로 작동하지 않습니다. 여기에 zip 파일을 다운로드하려고하는데 다운로드가 다시 시작되지만 그물 결과는 잘못된 zip 파일입니다.이력서 다운로드가 안드로이드에서 작동하지 않습니다.
BufferedInputStream in = null;
FileOutputStream fos = null;
BufferedOutputStream bout=null;
try {
downloaded=0;
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if(ISSUE_DOWNLOAD_STATUS.intValue()==ECMConstant.ECM_DOWNLOADING){
File file=new File(DESTINATION_PATH);
if(file.exists()){
downloaded = (int) file.length();
}
}
connection.setRequestProperty("Range", "bytes=" + downloaded + "-");
connection.connect();
size=connection.getContentLength();
Dialog.setMax(size);
in = new BufferedInputStream(connection.getInputStream());
fos=(downloaded==0)? new FileOutputStream(DESTINATION_PATH): new FileOutputStream(DESTINATION_PATH,true);
bout = new BufferedOutputStream(fos, 1024);
byte[] data = new byte[1024];
int x = 0;
while ((x = in.read(data, 0, 1024)) >= 0) {
bout.write(data, 0, x);
downloaded += x;
System.out.println(downloaded);
onProgressUpdate((int)(downloaded*100/size));
}
succes=true;
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
in.close();
bout.close();
} catch (IOException e) {
e.printStackTrace();
}
}
감사합니다.
질문에 몇 가지 세부 정보를 추가하십시오. 정확히 어떤 문제가 있습니까? 어떤 오류가 있습니까? 그렇다면 추적 추적을 게시 할 수 있습니까? 우리가 당신에게 대답하고 싶다면 더 자세한 정보가 필요합니다. –
사실 여기에 나는 zip 파일을 다운로드하려고 시도하고있다. 그리고 그것도 다운로드를 재개 할 것이다. 그러나 net 결과는 잘못된 zip 파일이다 .. –