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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vikassawant
    New Member
    • Mar 2009
    • 27

    #1

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

    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


    Code:
    HttpConnection URLConn = (HttpConnection) Connector.open(originURL + fileName);
    
            if (URLConn == null) {
    
                URLConn.close();
    
                return;
    
            }
    
            int length = (int) URLConn.getLength();
    
     
    
            // variables to read the origin file
    
            inputStream = URLConn.openInputStream();
    
            try {
    
                fileCon = (FileConnection) Connector.open(DEVICE_PATH + fileName, Connector.READ_WRITE);
    
                if (!fileCon.exists()) {
    
                    fileCon.create();
    
                }else{
    
                    fileCon.delete();
    
                    fileCon.create();
    
                }
    Thanks in advance.

    Thanks,
    Vikas Sawant.
    Last edited by JosAH; Mar 31 '09, 06:43 AM. Reason: fixed the [code] ... [/code] tags
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    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

    Comment

    Working...