You could instead read the file in a loop:
byte[] data = new byte[BUFSIZE];
int nread = 0;
while ( (nread = raw.read(data, 0, BUFSIZE)) != -1 )
out.write(data, 0, nread);
On Jan 26, 11:39 pm, "sagar.indianic" <[email protected]>
wrote:
> Hello everyone,
>
> I am trying to downlaod a file from the net. It is an mp3 file and
> big in size. I m able to get connection but when trying to create a
> bufffer for file, I get out of memory exception....
> please help
> its urgent...
> Code is:
> URL u = new URL("http://----------");
> URLConnection uc = u.openConnection();
> int contentLength = uc.getContentLength();
> InputStream raw = uc.getInputStream();
> InputStream in = new BufferedInputStream(raw);
> byte [] data=new byte[contentLength]; //getting outofmemory
> exception here..Hello everyone,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---