में डाउनलोड नहीं करना डाउनलोड एंड्रॉइड में डाउनलोड फिर से शुरू करने के लिए यह कोड ठीक से काम नहीं कर रहा है, हालांकि यह जावा एप्लिकेशन में ठीक काम करता है। यहां मैं एक ज़िप फ़ाइल डाउनलोड करने की कोशिश कर रहा हूं, और यह डाउनलोड फिर से शुरू हो जाएगा, लेकिन नेट परिणाम एक अवैध ज़िप फ़ाइल है।फिर से शुरू करें एंड्रॉइड
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();
}
}
धन्यवाद।
कृपया अपने प्रश्न में कुछ विवरण जोड़ें: आप वास्तव में क्या समस्या का सामना कर रहे हैं? क्या कोई गलती है? यदि हां, तो क्या आप थैक्टट्रैक पोस्ट कर सकते हैं? अगर हम आपको जवाब देना चाहते हैं तो हमें अधिक जानकारी चाहिए। –
असल में यहां मैं एक ज़िप फ़ाइल डाउनलोड करने की कोशिश कर रहा हूं ... और यह भी डाउनलोड फिर से शुरू हो जाएगा .. लेकिन शुद्ध परिणाम अमान्य ज़िप फ़ाइल है .. –