06-22-2011 04:18 AM
i am downloading & saving media files (videos/pdf) using following code. The issue is its working fine for small size mb files (1 mb to 18 mb) but for some files of 60 mb it stuck during downloading. or sometimes downloading not start. Is thr some size limit for byte array coz i am initializing it with lenght of file . this len contains bytes to read
int
len = (int) hc.getLength();
byte[] data = newbyte[len];
if(len > 0) {
intactual = 0;
intbytesread = 0;
while((bytesread != len) && (actual != -1)) {
actual =
dis.read(data, bytesread, len - bytesread);
bytesread += actual;
percentage = bytesread * 100;
percentage = percentage / len;
int p = (int) percentage;
ProgressIndicatorScreen.
this.model.setValue(p);
}
}
Solved! Go to Solution.
06-22-2011 04:25 AM
06-22-2011 05:22 AM
but for 69 mb file the process is not started even not completed 1 percent..
06-22-2011 05:33 AM
06-22-2011 05:40 AM
yes length is valid value.carrying no of bytes equal to 69 mb
06-22-2011 06:03 AM
plz tell me is thr someother built in api instead of downloading byte by btye data ?
06-22-2011 07:10 AM
06-22-2011 07:20 AM
any example to use it plz. or if i read data in chunks then i think it will sortou .
this example http://supportforums.blackberry.com/t5/Java-Develo
06-22-2011 05:41 PM
I don't understand why the KB article you have referenced is not useful for you.
In your case with a 69 Mb file, you should definitely download it in chunks and store it on SD Card while doing so, and I think the KB article you have referenced is perfect for doing that.
06-23-2011 12:24 AM
its using BufferedInputStream but no api exists agains it. I didnt find any api to import for using this function