Get a picture of the url. The stream is closed.

String url="http://.../image.jpg";                                InputStream inputStream = (InputStream) Connector.openInputStream(url);
                                     Bitmap image = null;                       BitmapField bf = null;
                                    try {
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   int ch;
                                         while ((ch = inputStream.read()) != -1)   {
     baos.write(ch);
                                       }
   byte[] imageData = baos.toByteArray();
   image = Bitmap.createBitmapFromBytes(imageData, 0, imageData.length, 1);
   bf = new BitmapField(image);
                                         _fieldManagerMiddle.deleteAll();
   _fieldManagerMiddle.add(bf);
} finally {
    if (inputStream != null)
        inputStream.close();
    }}

Hello, I want to add an image url to a bitmap image. The error is 'closed Stream. The image goes in my server and it has read and write permissions.

Thank you

Try the following.

       try
        {
            HttpConnection connection=(HttpConnection)Connector.open(url);
            int response=connection.getResponseCode();
            if(response==HttpConnection.HTTP_OK)
            {
                InputStream is=connection.openInputStream();
                int length=is.available();
                byte[] data=new byte[length];
                data=IOUtilities.streamToBytes(is);
                is.close();
                connection.close();
                image=Bitmap.createBitmapFromBytes(data,0,data.length,1);
            }
        }
        catch (Exception e) {
            System.out.println("Exception From Thread"+e);
        }

Tags: BlackBerry Developers

Similar Questions

  • Huawei P9 - I have many issues with getting my pictures from the phone to my Imac

    Huawei P9 - I have many issues with getting my pictures from the phone to iphoto on my Mac.

    Before the summer I bought a Huawei P9 phone, I can easily see the photos on the phone - I can't just them on my mac.  When I connect via a USB cable, it refuses my permissions.

    I try to use my Google account to view on the Mac and move the iPhoto - I can't work either! I can see them, I can't move them!

    I'm pulling my hair out and I have enough to do with! Help, please...

    Jim Hosking

    You need the phone provider support - there is a problem with the way their phone works and how to use it and has nothing to do with the Photos or iPhoto - if pictures is consistent with standards of good Photos and iPhoto won't work with it

    You may need special third party software for your phone load in Photos or iPhoto

    LN

  • my computer is connected to a new projector with a DVI and HDMI cable, and return the currency I installed correctly but I don't get a picture on the projector

    I connected my computer to a new projector with a DVI and HDMI cable, and return the currency I installed correctly but I don't get a picture of the projector, need HELP.

    Hi Bill,

    Thanks for asking this question to Microsoft Community.

    I will definitely help you to set up the projector, but before starting, I would ask you some troubleshooting questions.

    What version of the Windows operating system is installed on the computer? Do you get any error messages? Have you done a recent software or changes to the material on the computer?

    Here is a link that provides information on connecting to a projector. Go through it and check if it helps.

    Hope this information is useful and provide us with more information for further assistance. We will be happy to help you.

  • tried to connect my computer vaio laptop to my home theatre with a HDMI cable and get great picture on the tv

    Tried to connect my laptop vaio to my home theatre with a HDMI cable to run the windows media player music I get beautiful picture but no sound through home theater just the laptop itself... How do I get sound through home theater too?   It is model # SVE151190X

    Hi woodsman0692,

    To get sound from the HDMI, please activate in sound property.  To do this, press Windows + Q.  That will raise to SEARCH and type in the PANEL.  When Control Panel opens, select SOUND.  When sound property is displayed, right click on AVAMP and on the left, click on SET AS DEFAULT(pic below).  This noise turn sound via HDMI / av receiver system.

    (with plugged hdmi cable)

    (without the hdmi cable connected)

    Nick-

  • vCenter and the need to get a picture of the server

    I built a RHEL5 server with an application running on it called Wowza.  Now, what I need, is to create a vmx or eggs of this physical server. I downloaded VMWare vCenter Converter Standalone.  I need a picture to run in my VMWare Worktation 7.1.4

    Should I get the image I want?  Or there is another way to get a picture of this Linux server? When I ran first, it says that it can convert a physical machine to a virtual image.  Is my thinking correct that I

    1) click on Convert Machine

    (2) select 'Remote Machine A' and enter the credentials for my Linux server and in the field of family of the OS, I select "Linux".

    This will work via VPN because the Linux server is located remotely

    Thank you

    You must have a Windows machine at the remote location? Install the converter it and run it against the Linux machine. Even if my environment is mostly Linux I have a Windows workstation. In my Office I RPD for Windows of the machine and can run the converter and clone a virtual machine. Once cloned I can copy it on the desktop with PCs etc.

    Running intense service as converter remotely means that if your connection drops or some other glitch happens that it won't affect the conversion. You may lose your RDP connection and the VPN connection but converter will still work. If your connection drops for a copy of the CPS, you can just launch and resume the partial transfer.

  • need to get my pictures off the coast from the old computer to my new on my lightroom, had to download lightroom with my serial number not the fact the new computer doesn't have a cd player

    I fight with this forum, so if I keep asking the same question is because I'm not move here very well. I had to load my lightroom online on my new computer because I don't have a cd driver. Now that I've loaded it I need to get my photos on the old computer. Any ideas on how to do it, and I don't have creative cloud

    Hi tinap50,

    You can use an external hard drive to get all the images from your old computer to the new, then import into Lightroom.

    Kind regards

    Claes

  • Cannot get my pictures in the order I want.

    I can't get my photos in the order I want.  I do this:

    (1) select the photos I want in the main file using a color filter. Then, I select the filter to display a selection of photos.

    (2) I rearrange the photos in the order I want by drag-and - drop in the "film" at the bottom of the screen.

    (3) I select the photos newly built for export. If I export to a new file the new photos in the new reveert file to the old order. Strangely, if I have the cursor on the images of the film of the new file, they are numbered in my custom command but physically they were returned back to the order that they were in before I gave up and dragged.

    What should I do on custom order my photos and export them to a new file that will recognize this order? I've done this plenty before but suddenly something goes wrong.

    Thank you

    Craig

    LR by default to capture the time - are you by selecting the command file name in the toolbar?

  • I get no picture on the TV when using mini ipad with the Digital AV adapter.

    I get a white on my TV screen when I connect my mini ipad digital AV adapter except HDMI 1 showing in the upper left corner of the TV screen. My mini2 ipad works great with the same son and TV.  I tried two ipads with different TV but get the same result. The ipad mini works OK if not connected to the TV. Two minis are working on the same operating system setting.

    The Digital AV adapter can be finnicky.

    Have you tried simply unplug and plug the adapter with the HDMI cable connected with it?

    With the adapter always plugged into your iPad, have you tried a hard reset of your iPad by pressing the sleep/wake and Home buttons simultaneously until your iPad goes to the dark and restarts with the Apple logo, then release them buttons?

    Good luck!

  • How do you get your pictures once the phone has been reset

    I have problems with my iphone 6. It sends the text, e-mail messages which is gibberish and people at random. Also when I try to send a message the keys get stuck. I took it to the Apple store and they just reset, now I lost all my photos and contacts. AND the phone still has the same question. It's like I have a new phone (nothing about), but it's broken. What can I do?

    This iphone has been 1 year in last October.

    Restore the last backup of the phone before recovering.

  • How to get my picture to the original?

    I use Adobe old items 3 and inadvertently tried a selection of 'grid' and now it's on EVERY photo in my browser, even if I was only working on a picture of my granddaughter.  I need to UNDO everything including the original as and nothing does, including the CANCELLATION. Please help, I'm at witts end.

    I have not PSEv.3 any longer, but PSEv.8 I go to view > grid. Uncheck this.

    Who do it for you?

  • How to get a picture in the corner to move when a table is resized

    I have a simple table 2 column, menu on the left, to the right content and want a graphic to be placed in the lower right to enter and exit the page is resized but I want also overlap the text graphics.

    So I guess I use a tag Div AP to get the text on the image, but how do I move them dynamically in what concerns the resizing of the table?

    THX

    Kevin

    Thanks this is great!

    My next step is to learn how CSS works better and understand what you were doing just ;-)

    Kevin

  • Is it possible to get a picture of the iphone WITH the button "home" on Adobe Stock?

    I can't find again and it's ridiculous.

    This is probably because it would violate the terms for their contribution of photos that are an accurate representation of a brand.

  • When I want to pre print a message before you actually start to print I get a picture on the screen.

    When starting pre print, I don't see some treat the message that goes to fast to read, but suggests that the system is busy with something.

    I had a similar problem to Firefox, which I solved it by doing a re - initialize. Can I do in Thunderbird as well?

    There is no easy way, but ban you use the configuration editor to remove any entry that contains print. at the beginning of the year.

    I have no idea why Thunderbird stores these values, but their distance: their replacement after the next start with print, so you can't really go wrong by removing these preferences. Unlike other.

  • Memory to "fill" of two or more photos to get a picture of the Caribbean

    I use Photoshop Elements 9 on an Apple iMac with the last Lion operating system computer.  I've recently upgraded to 4 GB to 20 GB memory so I could 'sting' and 'fill' of two or more images to create a single

    Photo Caribbean.  I am able to 'stitching' multiple images together, but can't "fill" even two photos which were "sewn" together.  Surely 20MB of RAM should be much more than enough for "prick" and "fill."

    .

    several photos.  I use iPhoto to organize my photos and Photoshop Elements 9 for installation more complex.  I have contributed to a maximum of the RAM Photoshop Elements can be used in the 'Préférences' dialog box, but that doesn't

    support and I would like to increase the amount of RAM I can use in Photoshop Elements 9.  Can someone help me solve this BIG PROBLEM?  Please reply directly to my email address.  Thank you.

    Nicholas Barth

    [email protected]

    15 March 2012

    Elements is a 32-bit application, so he cannot see more than 4 GB of memory (actually it's more like 3.2) ever. You can try to set the editor preferences > performance as high as possible:

  • When I right click instead of the menu, I get a picture of a Web site I visit. The same list of links sugested (sharpen by typing an address).

    Right click and I get a picture of the entire window (tabs above, the entire site). In the upper right corner of this photo (photo is inside this menu after right-clicking straight or suggestions) I have my standard menu. When I try to point sth (on the menu) it starts flashing (picture, menu, picture...). It drives me crazy. I even tried system reinstall and it happens again.

    I'm working on laptop. It is not a beast but not some junk too.

    Any ideas?

    P.S, English is not my first language so I tried to make everything as clear as possible. If sth does not know just let me know.

    P.s2 I could use some of the built in dictionary to avoid misspellings, but I can't.

    Hello montone, maybe it's a problem with hardware acceleration - try updating your graphic driver, or in case this does not solve the problem, or there is no new version available at the time, disable hardware acceleration in firefox > options > advanced > General.

Maybe you are looking for