How to download 100 MB

Hi, everyone here

the cod below is to download large files which mostly discussed in this forum. It download a file about 2-3 MB while it is impossible to download a 100 MB file! always collapsed after charge. 2 Mb is what someone knows another way to download big files, clues will be a great help!

public class _DownloadCombiner extends Thread {

    private String remoteName;
    private String localName;
    private int chunksize;

    public _DownloadCombiner(String remoteName, String localName, int chunksize) {
        this.remoteName = remoteName;
        this.localName = localName;
        this.chunksize = chunksize;
    }

    private void method1()
    {

    }

    public void run() {
        try {
            int chunkIndex = 0;
            int totalSize = 0;
            /*
             * File connection
             */
            FileConnection file = (FileConnection) Connector.open(localName);
            if (!file.exists()) {
                file.create();
                file.setWritable(true);
                OutputStream out = file.openOutputStream();
                /*
                 * HTTP Connections
                 */
                String currentFile = remoteName;
                HttpConnection conn;
                InputStream in;
                int rangeStart = 0;
                int rangeEnd = 0;
                while (true) {
                    IOUtil.print("Opening Chunk: " + chunkIndex);
//                  conn = (HttpConnection) Connector.open(currentFile,
//                          Connector.READ_WRITE, true);

                    // ConnectionFactory start
                    ConnectionFactory conn_fact = new ConnectionFactory();
                    conn_fact.setAttemptsLimit(3);
                    ConnectionDescriptor conn_desc = conn_fact.getConnection(currentFile, TransportInfo.TRANSPORT_TCP_WIFI, null);
                    conn = (HttpConnection) conn_desc.getConnection();
                    // ConnectionFactory end

                    rangeStart = chunkIndex * chunksize;
                    rangeEnd = rangeStart + chunksize - 1;
                    IOUtil.print("Requesting Range: " + rangeStart + "-"
                            + rangeEnd);
                    conn.setRequestProperty("Range", "bytes=" + rangeStart
                            + "-" + rangeEnd);
                    int responseCode = conn.getResponseCode();
                    if (responseCode != 200 && responseCode != 206) {
                        IOUtil.print("Response Code = "
                                + conn.getResponseCode());
                        break;
                    }
                    IOUtil.print("Retreived Range: "
                            + conn.getHeaderField("Content-Range"));
                    in = conn.openInputStream();
                    int length = -1;
                    byte[] readBlock = new byte[256];
                    int fileSize = 0;
                    while ((length = in.read(readBlock)) != -1) {
                        out.write(readBlock, 0, length);
                        fileSize += length;
                        Thread.yield(); // Try not to get cut off
                    }
                    totalSize += fileSize;
                    IOUtil.print("Chunk Downloaded: " + fileSize
                            + " Bytes");
                    chunkIndex++; // index (range) increase
                    in.close();
                    conn.close();
                    in = null;
                    conn = null;
                    /*
                     * Pause to allow connections to close and other Threads to
                     * run.
                     */
                    Thread.sleep(1000);
                }
                IOUtil.print("Full file downloaded: " + totalSize
                        + " Bytes");
                out.close();
                file.close();
            } else {
                IOUtil.print("File already exists...");
            }
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }

    }
}

The approach outlined in this KB works for me for large files.

http://supportforums.BlackBerry.com/T5/Java-development/download-large-files-using-the-BlackBerry-mo...

Tags: BlackBerry Developers

Similar Questions

  • How to download audio files

    Music downloads

    just received a computer and don't know how to download songs - please tell me where I can buy songs (or y at - it somewhere I can get them for FREEligitimately or y at - it somewhere I can download an unlimited number for a fixed price?).  What should I do to download in windows media player?  and how to transfer the on a cd so that I can read on my portable cd player? Thanks in advance for your help. also, how many songs can I put on a cd?

    Wow! Lots of questions... I'll try to offer some info to help you get started.

    ===================================

    > just got a computer and don't know how to download songs - please tell me where I can buy songs

    ===================================

    A few choice...

    iTunes
    http://www.Apple.com/iTunes/

    Amazon
    http://www.Amazon.com/music-rock-classical-pop-Jazz/b?ie=UTF8&node=5174

    Wal-Mart
    http://www.Walmart.com/CP/music/4104

    ===================================

    > (or y at - it somewhere I can get them for FREE ligitimately or y at - it somewhere I can download an unlimited number for a fixed price?).

    ===================================

    If you want to "legal" downloads... they are pretty good pay-as-you-go...

    ===================================

    > what should I do to download in windows media player?

    ===================================

    The site you tΘlΘcharger can help with this info.

    ===================================

    > and how to transfer the on a cd so that I can read on my portable cd player?

    ===================================

    If your CD player is MP3... you can create a data CD that will play.

    Windows Vista
    Burn a CD or DVD in Windows Media Center
    http://Windows.Microsoft.com/en-us/Windows-Vista/burn-a-CD-or-DVD-in-Windows-Media-Center
    (Enlarge and read: to burn music, photos and videos to a CD or data DVD)

    If your CD drive is not compatible MP3, you will need to create an Audio
    (Music) CD.
    http://Windows.Microsoft.com/en-us/Windows-Vista/burn-a-CD-or-DVD-in-Windows-Media-Center
    (Enlarge and read: burn an audio CD to play on your CD player)

    ===================================

    > thank you in advance for your help.

    ===================================

    In advance?

    ===================================

    > also, how many songs can I put on a cd?

    ===================================

    A data CD is limited by the size of the file... so many MP3s, you can burn them to a data disc.
    If the MP3s on average 5 MBs each... you could burn more than 100 songs on a CD.

    An Audio CD (music) is limited by the duration, we must look at the minutes
    the CD. I have one here that says...   80 minutes - 700 MB if average of the air
    4 minutes... about 20 tunes by CD.

    Volunteer - MS - MVP - Digital Media Experience J - Notice_This is not tech support_I'm volunteer - Solutions that work for me may not work for you - * proceed at your own risk *.

  • Battery problem. How to reach 100% battery?

    Seem to be able to have 100% battery power, have message when click on the battery icon of "battery 50% available (plugged in, does not support).»   How to reach 100% battery?

    Hello

    References to Vista also apply to Windows 7.

    Check with support from the manufacturer of their books online and the drivers and their forums system
    (as applicable) for known issues. Some manufacturer issued BIOS and other updates to help the battery
    problems.

    ================================================================

    Follow these steps to remove corruption and missing/damaged file system repair or replacement.

    Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup

    Start - type in the search box - find command top - RIGHT CLICK – RUN AS ADMIN

    sfc/scannow

    How to fix the system files of Windows 7 with the System File Checker
    http://www.SevenForums.com/tutorials/1538-SFC-SCANNOW-Command-System-File-Checker.html

    Then run checkdisk (chkdsk).

    How to run check disk in Windows 7
    http://www.SevenForums.com/tutorials/433-disk-check.html

    =================================================================

    Other information that might help:

    Control Panel control - plan change Options - power plans - power - advanced settings
    Parameters for the drainage and the use of parameters (this is how much to use and not how much or how)
    long to load).

    In fact, what causes a lot of wear on a battery empties it too low on several occasions. With today
    systems overload are not a problem.

    Here are some tips to help and troubleshoot battery issues.

    Old battery? Unplug the power to the computer - remove the battery and clean the contacts with a pencil
    eraser (do not use this, if your battery is fine slots - just clean up the edges of the knife which fit in)
    them and be careful). Batteries are old, or it could be a problem with the computer.
    Check with the support of the machine system, and many of them have online forums.

    New Lithium-Ion type battery usually last longer if you do not unload their less than 30%
    However on a laptop that not extend their life a lot. Best is to use the a/c adapter
    When this is possible.

    I use the free version of BatteryBar to monitor my battery. Click on the green button on the
    Yellow box on the right side of the page to download the latest stable version.

    BatteryBar - free version available
    http://osirisdevelopment.com/BatteryBar/index.html

    Another good program

    Vista battery saver - free
    http://www.codeplex.com/vistabattery

    Problems with the lives of its use and the battery of power - Mr Fixit
    http://support.Microsoft.com/GP/windows_battery_power_settings

    You can also check with the manufacturer of system and forums that many use their own
    proprietary software to monitor the battery and they could be known problems with your battery.

    ============================================================

    Battery meter: frequently asked questions
    http://Windows.Microsoft.com/en-us/Windows7/battery-meter-frequently-asked-questions

    Battery saver
    http://Windows.Microsoft.com/en-us/Windows7/conserving-battery-power

    Solutions to common battery problems
    http://Windows.Microsoft.com/en-us/Windows7/solutions-to-common-battery-problems

    What is the precise the battery meter?
    http://Windows.Microsoft.com/en-us/Windows7/how-accurate-is-the-battery-meter

    ============================================================

    Try this - to make a Restore Point

    How to create a System Restore Point in Windows 7
    http://www.SevenForums.com/tutorials/697-system-restore-point-create.html

    How to do a system restore in Windows 7
    http://www.SevenForums.com/tutorials/700-system-restore.html

    Then Control Panel - Manager of devices - Batteries - Double click on each item - drivers - tab
    Update the drivers (which can do nothing) - then do a right click and UNINSTALL each - RESTART
    who will update the driver stacks.

    Problems with the lives of its use and the battery of power - Mr Fixit
    http://support.Microsoft.com/GP/windows_battery_power_settings

    I hope this helps and happy holidays!

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="" -="" mark="" twain="" said="" it="">

  • How to download free microsoft office in my iMac

    Please can someone tell me how to download free Microsoft office on my iMac?

    Microsoft Office is available as a free application or through a subscription service. It is not a free application, although there is a free trial for one month of subscription to the service (which requires a credit card: payment is taken automatically after one month unless you cancel it).

    The link to the Agency depends on what country you are; Start by Googling Microsoft Office.

  • How to download both my whole library to apple for android music listen offline?

    I noticed that it is possible to download music but one each time, how to download all at once to listen to offline on my android device.

    One at a time only.

  • How to download files from images on a PC?

    I'm trying to figure out how to download image files in bulk from my iPhone.  Photos are sent to me by members of the family using iPhones.  I don't know where they're going, but image files appear on my iPhone.  I just want to download these files on my PC.  I know how to send photos unique to me by email, but it's too labor intensive and time consuming.  Is it possible to send files from my iPhone photo to my PC?  I read all articles, FAQ Apple and tried to click on all the sharing options, but have had no success.

    iOS 9.2.1.  PC running Windows 7.  A lot of processor, RAM, etc.

    It works easy with photos from camera roll

    If I were you I would try using dropbox or something on both devices

  • How to download photo 360 on facebook

    Hello

    Could someone tell me how to download photo 360 on facebook? I mean some blog saying use exifTool. I need in (Terminal) and write the code? Help, please!

    Try the Facebook Help Center > https://www.facebook.com/help/

  • How to download the Strip ad on iTunes store

    How to download movie trailers of films on clashofthetitans?

    You can't download movies to the trailers.

  • How to download music from soundcloud to itunes?

    How to download music that plays on SoundCloud from my iTunes library?  The transferred files seem to not include the mp3 file.

    Hello...

    SoundCloud is not compatible with iTunes.

  • How movies download iPad

    How to download movies to ipad without using any browser

    Please years me quickly

  • How to download the whole google on iphone photo library?

    Hi all

    I can't find a guide or a suggestion on how to download my library of photos google together on my iphone 6 s 64GB.

    I want to have all my photos on my camera, because when I look at a photo of photo of google out of wifi coverage backupped it is displayed at low resolution.

    There are a lot of guide and explanation on the synchronization and backup google photo photos, but I found nothing on the reverse.

    For the moment I downloaded on the imac to my google photo library that has this structure

    You have an idea how can I copy this library to my iPhone?

    The idea is:

    (1) CANCEL all the photos of my library Photo of Google (via the web with my imac)

    (2) copy the library Photo of Google from my imac for my iphone (how can I do?)

    (3) sync a backup from iphone to Google Photo with Photo Google app

    Anyone know what is the correct procedure for question 2) above?

    Thanks in advance

    Sync photos from your computer to your device via iTunes - Apple Support iOS

  • How to download and record a song on Firefox?

    When I want to download a song, it goes through flash player only, please tell me how to download and record a song on my phone using Firefox.

                              I will be thankful to you.
    

    long press flash and select Save audio

  • How to download photos of 'Photos' to any Web site

    I usually download the photos from my SD card on "Photos" app on Mac.

    Recently I wanted to download a photograph of the 'Photos' to a Web site. But when I click on the upload button, I get a finder window where in which I'm not able to see the photos of the "Photo". Can anyone help me on how to download photos of 'Photos' on any Web site through a browser.

    Thank you

    Babunath

    You can right click on your "iPhoto Library" (in the Finder, at least) it will open like a folder and press "Show Package Contents". The original images are in the original named file and images published in the "modified" folder (in iPhoto) I'm not sure of the folder "Data" (an alias for Data.noindex), it may just be a backup. To check, you can also click with the right button on a photo in iPhoto and select "Show the file" and it will take you to the source location.

    You can create aliases to modified, the data and original folders to facilitate access.

    EMAILING STUFF: When you have a 'Open file' dialog box (to choose the files to download, etc.) on the left, there is also a section of media, which makes it convenient to access iPhoto photos. Pretty easy actually, not need to navigate in a package.

  • How to download the youtube videos with downallthem add on as there are so many downloadable

    When I use downthem all, there are many jpeg, watch, containing the link of downloadale in the youtube pages appear. How to download audio and video of the selected link using this add on. It seems to be a good add on but I think he's said little about downloading audio and video.

    Sorry, I do not use this extension myself. You will need to wait for a support of assistance that uses actually the extension of aid.

  • How to download pictures from computer to AT300

    How to download pictures from the tablet computer

    the photos are in alphanumeric order and I like to keep in the present order, once downloaded

    Thank you
    Jim

    Related topics in this forum you can talk to Toshiba.
    To be honest, I n t t see and Toshiba here connection

    However, you can connect the tablet to the laptop (I guess it helps a micro USB interface) and could move the files to the new tablet.

    After the images have been moved to the Tablet, you can use a file Android App Manager to have access to the files.

Maybe you are looking for