Hello folks,
I've got the following code:
BufferedInputStream stream = new BufferedInputStream(new URL("my url
that points to a binary file").openStream(), 1024 * 1024);
BufferedOutputStream fos = new BufferedOutputStream(new
FileOutputStream(downloadFile));
byte buf[] = new byte[1024 * 1024];
int numBytesRead;
do
{
numBytesRead = stream.read(buf);
if (numBytesRead > 0)
{
fos.write(buf, 0, numBytesRead);
}
} while (numBytesRead > 0);
fos.flush();
fos.close();
stream.close();
buf = null;
I'm trying to download a 6.5MB file from the URL to the SD card and
this process takes an extremely long time both on my dev phone 2 (10
minutes or more) and in the emulator (way longer).
I've also tried getting the input stream this way:
URLConnection connection = new URL("my url that points to a binary
file").openConnection();
connection.connect();
BufferedInputStream stream = new
BufferedInputStream(connection.getInputStream(), 1024 * 1024);
With no difference in how long it takes.
Can someone tell me why the download is so slow? I've got my app on
the iPhone doing the same thing and the file will download in under a
minute, maybe 2 minutes max.
Any advice for how to optimize my download code would be appreciated.
Thank you,
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 [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-developers?hl=en
To unsubscribe from this group, send email to
android-developers+unsubscribegooglegroups.com or reply to this email with the
words "REMOVE ME" as the subject.