Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
shaina123
Posts: 59
Registered: ‎03-01-2011
Accepted Solution

size limit of byte[] array

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);

}

}

Please use plain text.
Developer
simon_hain
Posts: 15,558
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: size limit of byte[] array

i don't think there is a size limit for a byte array, it is most likely a connection issue. downloading large files has been difficult forever.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
shaina123
Posts: 59
Registered: ‎03-01-2011

Re: size limit of byte[] array

but for 69 mb file the process is not started even not completed 1 percent..

Please use plain text.
Developer
simon_hain
Posts: 15,558
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: size limit of byte[] array

check if the reported length is a valid value, sometimes the server reports -1 or other nonsense despite a large file being there.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
shaina123
Posts: 59
Registered: ‎03-01-2011

Re: size limit of byte[] array

yes length is valid value.carrying no of bytes equal to 69 mb 

Please use plain text.
Regular Contributor
shaina123
Posts: 59
Registered: ‎03-01-2011

Re: size limit of byte[] array

plz tell me is thr someother built in api instead of downloading byte by btye data ?

Please use plain text.
Developer
simon_hain
Posts: 15,558
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: size limit of byte[] array

http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/io/IOUtilities.html#streamToBy...

i don't think it'll solve the problem, but that's the method i usually use
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
shaina123
Posts: 59
Registered: ‎03-01-2011

Re: size limit of byte[] array

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-Development/Download-large-files-using-the-BlackBerry-Mo... using bufferedinputstream but its not supportable (no api)

Please use plain text.
Developer
peter_strange
Posts: 19,513
Registered: ‎07-14-2008

Re: size limit of byte[] array

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. 

Please use plain text.
Regular Contributor
shaina123
Posts: 59
Registered: ‎03-01-2011

Re: size limit of byte[] array

its using BufferedInputStream  but no api exists agains it. I didnt find any api to import for using this function

Please use plain text.