By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,321 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,321 IT Pros & Developers. It's quick & easy.

How to reduce the time to download file from server using HTTP connection

P: 27
Hi,

I m facing some critical problem for downloading 5mb file from server. Does anyone know?



How to reduce the time to download file from server using HTTP connection?



Code I m using is


Expand|Select|Wrap|Line Numbers
  1. HttpConnection URLConn = (HttpConnection) Connector.open(originURL + fileName);
  2.  
  3.         if (URLConn == null) {
  4.  
  5.             URLConn.close();
  6.  
  7.             return;
  8.  
  9.         }
  10.  
  11.         int length = (int) URLConn.getLength();
  12.  
  13.  
  14.  
  15.         // variables to read the origin file
  16.  
  17.         inputStream = URLConn.openInputStream();
  18.  
  19.         try {
  20.  
  21.             fileCon = (FileConnection) Connector.open(DEVICE_PATH + fileName, Connector.READ_WRITE);
  22.  
  23.             if (!fileCon.exists()) {
  24.  
  25.                 fileCon.create();
  26.  
  27.             }else{
  28.  
  29.                 fileCon.delete();
  30.  
  31.                 fileCon.create();
  32.  
  33.             }
  34.  
Thanks in advance.

Thanks,
Vikas Sawant.
Mar 31 '09 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
You only showed us the preamble of the entire process; your connection speed is the most important factor for the downloading time here. Try to read 4KB or so blocks every time.

kind regards,

Jos
Mar 31 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.