is there any suggestion on this issue?

On Mar 21, 2:38 am, Stormtap Studios <r...@stormtapstudios.com> wrote:
> Hello folks,
>
> I have the following code todownloada binaryfilefrom a URL:
>
> private static final int BUFFER_SIZE = 1024 * 1024;
>
> BufferedInputStream stream = new BufferedInputStream(new URL(<MY
> URL>).openStream(), BUFFER_SIZE);
> BufferedOutputStream fos = new BufferedOutputStream(new
> FileOutputStream(outputFile));
> byte buf[] = new byte[BUFFER_SIZE];
> int numBytesRead;
> do
> {
>         numBytesRead = stream.read(buf);
>         if (numBytesRead > 0)
>         {
>                 fos.write(buff, 0, numBytesRead);
>         }} while (numBytesRead > 0);
>
> fos.flush();
> fos.close();
> stream.close();
> buf = null;
>
> Thefilethat I'm downloading is 6.5MB.  On the iPhone version of my
> app it takes about a minute todownload, maybe less on good days.  On
> the Android Dev Phone 2 I'm testing on it takes 10 - 15 minutes todownload, 
> it's EXTREMELY slow.
>
> I am looking for any and all advice on how to speed up thedownload
> for large binary files.
>
> One thing I tried was to speed up the writing to the SD card by
> filling up buf, and then only doing fos.write() when the buffer was
> full (so roughly 6 and a half writes instead of lots of mini writes).
> This seemed to have no effect on the overall process, which confirms
> IMO that the slow part is definitely reading from the URL stream.
>
> Thanks very much.
>
> Robert Hawkey

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to