I have 40 MB file in server and i am downloading my file using
HttpURLConnection c = (HttpURLConnection) u.openConnection();
 c.setRequestMethod("GET");
 c.setDoOutput(true);
 c.connect();
 FileOutputStream f = new FileOutputStream(new File("trips.xml"));
 InputStream in = c.getInputStream();
 byte[] buffer = new byte[1024];
 int len1 = 0;
 while ( (len1 = in.read(buffer)) != -1 ) {
  f.write(buffer,0, len1);
this code seems working fine but it is taking too long. is their any way I can make this process faster.
/minhaz
Use larger input buffer than 1 KB. The faster you empty buffer, the faster network stack can continue downloading. This should help:
byte[] buffer = new byte[50*1024];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With