How to get the gif file hosted by using the Http connection?

Hello

I have an application that downloads animation gif from a server by using the http connection. Here is the code I use to download the image.

try {

            httpConnection = (HttpConnection) Connector.open(url, Connector.READ_WRITE);            httpConnection.setRequestMethod(HttpConnection.GET);

            if (httpConnection.getResponseCode() == HttpConnection.HTTP_OK) {                DataInputStream dS = httpConnection.openDataInputStream();

                byte[] data = new byte[dS.available()];                dS.read(data);

                gifImage = (GIFEncodedImage) EncodedImage.createEncodedImage(data, 0,data.length);

            } else {                throw new Exception("ResponseCode:" + httpConnection.getResponseCode());            }        } catch (Exception e) {                        gifImage = null;            e.printStackTrace();        }

the problem with this code is, when the gif file is 1175 bytes above, it does not load the gif.

example:-If the gif on the server is 1500 bytes, this code retrieves only 1175 bytes.

I think that the rest of the bytes are sent in a different package. But how to get them.

can someone please provide a code for buffering the inputstream?

any help is appreciated.

Dieye

Advertisement

Hmm, nobody seems to know how to do, it seems. Here's how I did it.

            httpConnection = (HttpConnection) Connector.open(url, Connector.READ_WRITE);
            httpConnection.setRequestMethod(HttpConnection.GET);

            int responseCode = httpConnection.getResponseCode();
            if (responseCode == HttpConnection.HTTP_OK) {
                inputStream = httpConnection.openInputStream();
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

                byte[] buffer = new byte[256];
                int len = 0, imageSize = 0;

                while (-1 != (len = inputStream.read(buffer))) {
                    byteArrayOutputStream.write(buffer);
                    imageSize += len;
                }

                byteArrayOutputStream.flush();
                byte[] imageData = byteArrayOutputStream.toByteArray();
                byteArrayOutputStream.close();

                gifImage = (GIFEncodedImage) EncodedImage.createEncodedImage(imageData, 0, imageSize);

Tags: BlackBerry Developers

Similar Questions

  • HP 9470 m Ultrabook, Win8 - how to get the 3G connection?

    Hello

    I got a Ultrabook 9470 m of work with Win7 installed. Everything works, cool, but I wated Win8 (64 bit) for my own stuff. So, I installed Win8 (dual-boot) for my use personal. Of course, I have no HP drives or whatever it is. -No worries, I found all drivers for Win8-64 in this site ok. And now everything is recognized correctly.

    But I don't know how to get the 3G card to connect. On Win7 HP connection manager takes care of that. But there is no connection manager for Win8. And google results only direct me to choose the network in the bar 'charm '. Great, but there are only available WiFis appear...

    ... --- ...

    Well, I finally got this resolved. -As usual, it'S just a driver issue, as always with Windows... I suppose that there is nothing new under the stars.

    In any case. Thanks for Cloud_Strider to point to the firmware upgrade. I did, but it alone did not help. BUT I don't know if it was still a part of the solution. So, thank you!

    Unfortunately, Ericsson or Navatel drivers broadband did the trick. -It's the only ounces available on the site of HP support for this laptop. = (Fortunately, I had (finally) look in Device Manager to see what drivers are installed. Seems that this braodband card is a HP un2430. Looking for these drivers for WIndows 8 on Google showed me finally good page on HP which she link to fresh (from March 2013) drivers for this card.

    After removing the old drivers (+ restart) and new (+ reset) installation, broadband is now available. I now write this with happiness through 3 G connection. =)

  • How to get the best connectivity WLan on Satellite U200

    I wonder if everyone is disappointed by the scope of the U200 wireless.

    I always find that my laptop shows 2 bars for their my BT hub (on the floor) when my eeepc located beside the laptop displays 5.

    I also found in other places that my partners laptop detects wireless networks much more that I do.

    I would prefer to explore the possibility of increasing my wireless connection before moving my BT hub to give me a better reception. being able to find the hub with my laptop wherever I am at home (like my partners)

    Anyone got any ideas please?

    OK, a few points of view but no ideas... I've now experimented with an external wireless adapter

    I have a toshiba satellite pro u200 with built in WiFi. I have also 2 adsl providers in the House (one is cancelled as soon as I am happy with the new - but I'll take the opportunity to experiment at the mo to try to resolve some problems)

    I have a wireless router in my office (the service of Virgin Media 2 MB - VM), the other is upstairs (BTHomehub 8 mb - BT)

    Using the built-in tosh Wireless adapt if I'm sitting 2 laptops side by side on my desk both pick up VM 100%. (tosh and eeepc)-c' is the case that the router slot in the Office!

    If I'm sitting the same 2 latops on my desk and get them to connect to BT, the onlys tosh gives 2 bars, the eeepc 100%. (by bars, I mean view available networks - see 5 bars to show the strength of connection)

    If I then plug an external 108Mbps Netgear WG111T Wireless USB 2.0 for the tosh connection adapter improves to 4 bars.

    can I do the built in WiFi on the tosh to improve things or am I better to use an external adapter. If I use the outside how tosh knows which adapter to use? as I have the switch wireless to the position we don't if this activate the integrated?

    Allow the pc show the network show the icon when connected and can see the speed to 54Mbps - whatever that means?

    shouldn't I expect to see 108 Mbit/s if that's what the external netgear is capable of?

  • How to get the required connection pool data source?

    Hi we have created two pools of connections with two different userid to restrict access to the database. now I have 2 pools. so if I want to get the connection to a specific pool how to do this?

    Use the JNDI string. When you created your pools you created the jndi names. So when connecting to the data source, you specify jndi. That's how.

    Your postal code if you have a problem.

  • Satellite Pro A100 - how to get the Wlan connection works

    Help!

    I'm a total beginner, and my problem is I can get a connection without wire only when I'm really close to my BT hub.
    My son has a laptop and gets a good connection anywhere in the House and even outside.

    He thinks I have a dodgy wireless adapter, this could be the problem?
    Can I fix it myself?

    Maybe download a new driver?
    Any suggestions would be much apreciated.

    TOSHIBA SATELLITE PRO A100

    Hello

    Your ad is not really useful.
    I mean that there is no detail about your problem
    You should first check if the laptop supports the wireless network card.
    This can be done in the Device Manager.

    Usually the WLan card must appear in Manager devices-> network adapters.
    If it s are not it is that the WLan card is not built in or the driver WLan is not installed. If the WLan driver is not installed then you should see yellow exclamation (or unknown device).

    But if the wireless network adapter is listed correctly then you should check if the WLan notebooks have been enabled. In order to activate the WLan you have to press FN + F8 and you put the switch on IT until the small LED flash.

    Finally, to configure the WiFi connection (right name WLan, encryption settings, etc...)

  • How to get the files to and from the host

    Is there something that I can read which explains how to get the (ftp, memory stick or other) files to and from the host?

    Sorry if this is a noob question, I looked but could not find something specific...

    There are many ways of doing so:

    1 activate not supported ssh and scp use

    2. use VI Client access to your storage space on configuration files and server transfer

    3 configure the iSCSI or NAS to deal directly

  • How to get the string (specified by row and column) of txt file with labview

    Hello world

    How to get the string (specified by row and column) of txt file with labview

    THX

    As far as I know, a text file has no column.  Be more specific.  Do you mean something like the 5th word on line 4, where the words are separated by a space, and lines are separated by a newline character?  You can read from the spreadsheet String function and set the delimiter to a space.  This will produce a 2D channels table.  Then use the table to index and give the line number and column number.

  • How to get the parameter values of a step type custom when I create file and adding a type of step seq

    I use lv 8.5 and teststand 4.0.

    I did a step type custom and recorded at the MyTypes.ini in pallets of type.

    I specified a default module by opening the properties of the custom step of *.ini type window, then I put some values of the parameters.

    T1) when I open teststand and I add the custom step type manaully in seq file, the labview module parameter values are represented.

    But, if to use file (create and add support prototype stage), the labview module parameter values has the default value.

    Using joint file, how to get the setting custom step type values I put in *.ini?

    Q2) each type of step are automatically by name through the use of LoadTypePaletteFilesEx. When I open teststand and I add the custom step type manaully in seq file, the module is loaded automatically. Inside the attachment, I use a prototype of charge and a fixed path where the module labview is to load the labview module.

    Can I load module automatically without using a prototype of charge or how can I get a dynamic path of type step?

    I solved Q1 for myself by using the mapping tab of the parameter within the configuration to the default module window.

    Everyone knows Q2?

    Thank you.

  • How to get the JOINT-2 log file

    Hi, we installed in the 6500 system JOINT-2 cat. Anyone know how to get the syslog JOINT-2 file? and how config to send the log to syslog server? I know that these two questions are quite simple, but I've yet to find answers.

    Any help would be greatly appreciated.

    You can get the JOINT events to the CETS format. Using the Manager of IPS or other tool to collect these logs.

  • How to get the fnd_profile.value in the host program

    Hi all

    How to get the FND_PROFILE. VALUE('ORG_ID') in the host program.

    I loved not below, but it failed.

    v_return =' $ORACLE_HOME/bin/sqlplus - s $FCP_LOGIN < < END

    set pagesize 0

    trigger the echo

    fnd_profile. Value ('ORG_ID');

    EXIT;

    END '

    echo $v_return

    but it error with the message: Retrun value SP-0734: unknown command beginning "fnd_profile...". »

    Kind regards

    UVA

    > but it error with the message: Retrun value SP-0734: unknown command beginning "fnd_profile...". »

    .. .who is the same thing that will happen if you run SQL * more and type "fnd_profile.value...". »

    Assuming that fnd_profile.value is a function, you must select from the something (say double) or assign to a variable.

  • How to get the cpu host machine virtual mhz by PowerCLI

    How to get the cpu host machine virtual mhz by PowerCLI

    Thank you

    TEST.JPG

    The following command of PowerCLI will list the maximum cpu MHz for all of your virtual machines from the host:

    Get - VM | Select-Object - property Name,@{Name='MaxHostCpuMhz'; Expression = {$_.} NumCpu * $_. VMHost.CpuTotalMhz / $_. VMHost.NumCpu}}

  • How to get the mobile applications other than phonegap Build Service apk file in Dreamweaver CM³

    How to get the mobile applications other than phonegap Build Service apk file in Dreamweaver CM³

    Dreamweaver is a tool, not an install Android of web authoring tool.

  • How to get the host name of the physical computer inside a virtual machine until the user logs in Windows?

    I don't know if this is the right place to post this question, I develop software to support VMWare PCoIP and need to know how to get the host name of the physical machine (which manages the virtual machine and View Client) within a virtual machine before the user logs in Windows of the virtual machine.

    I understand there are two ways to read the host name, via the HKEY_CURRENT_USER\Volatile Environment registry and environment variables, but they are available once the user is connected. I need info before the user connects.

    Is there a VMware API that can be called or asked the host name?

    Thank you.

    Not on the broker, but there are the startup scripts to log on to the computer virtual itself: http://pubs.vmware.com/view-52/topic/com.vmware.view.integration.doc/view_integration_startsession_script.9.2.html

    Note that these executed when a virtual desktop computer allocated connection, not to the point that the client connects - it is possible for the customer to not complete the connection (crash, cancel, network failure) and so any what solution you design must handle this.

    Mike

  • During the import of my camera or a file in Lightroom 5 my pictures are too exposed by 1-2 stops, while they are well exposed on the screen of the device. How to get the "right-exposed images on the screen?

    During the import of my camera or a file in Lightroom 5 my pictures are too exposed by 1-2 stops, while they are well exposed on the screen of the device. How to get the "right-exposed images on the screen?

    There is an option in your Lightroom preferences, under the general tab, "treat JPEG files next to raw in form of images". If you have this option is checked, then Lightroom will import and view your first two and JPEG files. You use the active D-lighting on your camera? If you are, you must disable this feature.

  • How to get the path of the vmdk to a VM stop file?

    Hi guys,.

    How to get the path of the vmdk to a VM stop file in ESX Server via the VIX API?

    I try to get it via the VixVM_ReadVariable() function. but it seems that this function requires that the virtual machine is power on.

    I don't want to go the virtual machine started, I just want to know if I can get the path of the vmdk file when a virtual machine is power off.

    Thanks in advance.

    Sorry, I don't have any samples.

    However, if you look at the layoutEx of the managed object VirtualMachine field, you will see that the VirtualMachineFileLayoutEx data object has a field "files" which should contain the paths of affected files.

    I hope that it should be able to help get started.

Maybe you are looking for

  • Support assistant install script error

    HP Pavilion DV - 7 1247dx, Vista Home premium. during the installation of support Wizard I get a script host error "library not registered. 8002801 D code. Program continues to settle, but not computer does not appear at the bottom of the support Ass

  • Control an event in a Subvi

    Hi all I have a main VI and a Subvi (somewhat complicated one) that works with a structure of the event. I need a way to bind a button (the trigger) in this case VI to a button in my main VI. I know there isn't an easy way to do it, and I'm a newbie

  • HP 15-R007tx: need of Wifi and Bluetooth Driver for HP notebook 15-R007tx

    need driver wifi and Bluetooth for model No. HP 15-R007tx product id G8D31PA network control details- PCI\VEN_1814 & DEV_3290 & SUBSYS_18EC103C & REV_00 PCI\VEN_1814 & DEV_3290 & SUBSYS_18EC103C PCI\VEN_1814 & DEV_3290 & CC_028000 PCI\VEN_1814 & DEV_

  • Reg add to change the profileimagepath

    HelloI'm changing a user profile image path (located in: HKEY_LOAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/ProfileList/SID here (which is the name of reg key) I want to change the named profile image path value that is in the registry ke

  • Windows will not configure my computer from recovery disks...

    I have a HP desktop computer and my hard drive failed.  I bought a new hard drive.  I tried to reinstall windows on the new drive using the recovery discs, I did when I first bought my computer.  It goes through the process of formatting and installa


HashFlare