is it possible to save an image downloaded from net?

Hi I need to save an image downloaded from the net? How can I make it possible? is it possible to result in the RecordStore? and then use it later when we want?

am in a difficult deadline please help me!

Hello

use code below...

 String Imagedirectory= System.getProperty("fileconn.dir.photos");

            try
            {
                System.out.println("Imageurl="+imageurl.trim());
                HttpConnection ImagehttpConn = (HttpConnection)Connector.open(imageurl);//,Connector.READ_WRITE, true);
                ImagehttpConn.setRequestMethod(HttpConnection.POST);
            //  ImagehttpConn.setRequestProperty("Content-Type", "Image/jpeg");

                int status= ImagehttpConn.getResponseCode();

                if(status== HttpConnection.HTTP_OK)
                {

                    is = ImagehttpConn.openDataInputStream();

                    StringBuffer Imagedata=new StringBuffer();
                     int chr;

                        while ((chr = is.read()) != -1)
                        {
                            Imagedata.append((char) chr);
                        }
                        System.out.println("Imagedirectory"+Imagedirectory+imagename);
                        writeFile(Imagedata.toString().getBytes(),Imagedirectory+imagename);
                    }

                if(is!= null)
                is.close();
                 if(ImagehttpConn!=null)
                     ImagehttpConn.close();     

            }
            catch (IOException e)
               {
                Dialog.alert("IOException2");

            } 

and this for write the image //

private void writeFile(byte[] data, String fileName)
      {
            FileConnection fconn = null;
            try {
                    fconn = (FileConnection) Connector.open(fileName,
                                    Connector.READ_WRITE);
            } catch (IOException e) {
                    System.out.print("Error opening file");
            }

            if (fconn.exists())
                    try {
                            fconn.delete();
                    } catch (IOException e) {
                            System.out.print("Error deleting file");
                    }
            try {
                    fconn.create();
            } catch (IOException e) {
                    System.out.print("Error creating file");
            }
            OutputStream out = null;
            try {
                    out = fconn.openOutputStream();
            } catch (IOException e) {
                    System.out.print("Error opening output stream");
            }

            try {
                    out.write(data);
            } catch (IOException e) {
                    System.out.print("Error writing to output stream");
            }

            try {
                    fconn.close();
            } catch (IOException e) {
                    System.out.print("Error closing file");
            }
        }

Tags: BlackBerry Developers

Similar Questions

  • How can you save an image downloaded to your folder of class?

    Hi guys,.

    I would like to know if it is possible to record images uploaded in your file of the application. For example, in eclipse, under my BB application, I created a folder images in the src directory. I would like to save the image to this folder.

    When retrieving the image to use, I use ' images/test.png' so I tried to make a backup of "images /" but it does not work.

    I tried this link, but it does not work. Because, for example, they use

    fileconn.dir.photos
    

    http://supportforums.BlackBerry.com/T5/Java-development/is-it-possible-to-save-an-image-downloaded-f...

    I can't possibly store all the images to use for my application in the folder of photos of BB.

    Please help me on this.

    Files that are generated with the source cannot be changed once the application was packed. The files that the application downloads must be saved using one of the mechanisms of data storage that offers the rim: database SQLite, RMS, persistent store, the device memory, card SD or Runtime store. See the category of storing data in the documentation of the API for more information.

    Files that are provided with the application are accessible using Class.getResourceAsStream () or Bitmap.getBitmapResource (). If you put a "xyz.png" file in a folder "res" and "res" are inscribed on the way to build in the project settings, then the path to the file is ' / xyz.png '. If you put it in a subfolder 'images', the path is "/ images/xyz.png. If you place the file in the same folder as the source of the class mypackage. Foo (i.e., "src/mypackage/Foo.java"), then the resource can be found as Foo.class.getResourceAsStream ("xyz.png") (without a leading "/") or as "/ mypackage/xyz.png" using any object of the class.

  • Best way to save the images streaming from the web to device?

    We have an app to browse a catalog this content of stream of a web server. There is an image for each product, some in JPG format and some in PNG format. Our server is fast and reliable, so everything worked without problems so far, but we would like to give users the ability to save data on their device, so they don't have to listen to every time. I've only worked with before SharedObjects, which are capped at 100kb and will not help in this situation.

    What would be the best approach for storage of images and keeping them is crushed in the updates? Save an uncompressed Bitmap uses too much storage space. Adobe's JPEGEncoder class is completely useless because it takes 10 to 30 seconds to save an image of medium size on a typical device. Also, he does not sense of re - encode jpg files, and we must preserve transparency in png.

    At the moment we are using a loader to retrieve images and using loader.content to access the image data in the code. Is it possible to save the image file in its original local format when downloaded with a charger? We would like the images stored in the application data and not available through the gallery. With regard to the registration of the data for each product (price, description, etc.), the built-in SQLite support would be enough or should we create our own files?

    Thanks for the tips!

    Ah, I got it. Existing files are checked as indicated cmholden. If the image is not stored locally, we use URLStream to load the image file on the web. We can then save the file directly via the ByteArray to the URLStream and then use our code existing loader to load the ByteArray even as a DisplayObject. I was worried there would be some downturn app to save the files, but the change in performance is negligible and of course once the images are saved on the device they charge a lot more quickly the next time the application is run!

  • Is it possible to save an image as one. PSD document and as one. PNG file in the folders specified when running a script?

    I have several folders full of images that must be a watermark. I created an action that watermarks images and I ran a script that draws images in the folder and saves the most accomplished in another folder. The problem is that I need these images to be saved as both. Png and PSD files. I need of the. PSD files and the. PNG files to go into separate folders based on file types, however. Is this possible? I tried looking around for answers and I was not able to find the information I need.

    I'd appreciate any help I can get with that! Thank you.

    You can see if Image Processor Pro can do what you want:

    PS-scripts-browse/Image Processor Pro / Betas on SourceForge.net

  • cannot change the images downloaded from the iphone 4S

    Photos uploaded from iPhone4s on PC Windows 7 cannot be renamed, copied, changed or anything else. I get a message "error code: (0 x 80070057) '"

    Photos uploaded from iPhone4s on PC Windows 7 cannot be renamed, copied, changed or anything else. I get a message "error code: (0 x 80070057) '"

    ===============================================
    I don't know if the following links answer your question, but
    they may be worth a visit:

    Good luck and * proceed at your own risk *.

    FWIW... There is a very long discussion (several pages) to the
    following link:

    Cannot change the imported iPhone 4S photo
    https://discussions.Apple.com/thread/3444951?start=0&TSTART=0

    More Discussion

    iPhone 4S image properties is not compartible with Windows?
    Editing can be done on the computer due to the error
    "Windows Photo Viewer cannot save changes to this picture.
    because there is a problem with the properties of the image file".
    Any help?
    https://discussions.Apple.com/message/17291884#17291884

    More Discussion:

    We cannot turn a few photos in Windows 7 (but can turn others)
    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-pictures/cant-rotate-some-photos-in-Windows-7-but-can/3a809845-9144-4BB1-9bb3-ab4f5b856524

    A simple solution is to open the photos in paint or most other
    digital image editor and modify it.

    Some people have reported success using the following free download
    to remove the metadata.

    Property restrictions stripper iphone 4S (JPEG & PNG Stripper)
    http://www.SteelBytes.com/?mid=30&cmd=download&PID=15

    Here's a way to turn...

    Easily turn locked iPhone 4 and 4 s Photos in Windows 7 with
    the rotator Lossless JPEG free
    http://www.daleisphere.com/easily-rotate-locked-iPhone-4-and-4S-photos-in-Windows-7-with-the-free-JPEG-lossless-Rotator/

    Free download JPEG Lossless rotating
    http://annystudio.com/software/jpeglosslessrotator/

  • Impossible to rotate the images downloaded from the iPhone

    original title: when I download pictures of the iphone.

    When I upload photos from my iphone to my pc (win 7), I'm unable to rotate the images and save the changes. An error message comes up saying unable to process changes made to the image due to a problem with the properties of the image file.

    Right-click on the file and point to open with and click on the paint,

    Using wallpaper Rotate.

    Open videos with windows movie maker.

  • Save the images imported from an sd card

    I have to do something stupid. I downloaded pictures from a SD card to Lr, but although they appear in recent import I get a window saying file is not found. Image appears in the catalogue and the library, but I'm not (them) in the finder. Maybe another clue, when I do a spotlight for file number search, I get a different picture. I just downloaded Lr who used PSE 14 for several years.

    It is possible that you have imported to a different location that you thought. Have you tried right-clicking on an image and choose the option to display the image in the Finder?

  • Image downloaded from the server: Blue effect

    Hello

    I downloaded the Image to the server. Holding her blue effect.

    Code or even is:

    ImageView* imageView = page->findChild("image");
            if (success) {//show the image
                if (imageView) {
                    QImage qImage = img->getImage().rgbSwapped().scaled(768, 500, Qt::KeepAspectRatioByExpanding); //resize image to fit container
                    imageView->setImage(fromQImage(qImage));
                }
            }
    

    The shadow of the lights, please...

    What is the img type? I don't think you need the rgbSwapped.

  • Adding dynamic elements or Images downloaded from the internet to a HorizontalFieldManager

    Hello

    I create an application that uses a HorizontalFieldManager to display images from an RSS feed.
    As I don't know how many images is coming in rss, I created a function that takes the RSS feed Manager and reads all the fields from image on it, and then creates a toolbarButton with the URL to download the image.

    The toolbarButton class is just a stretch of a BitmapField with an inner thread to download images using HTTPConnection.

    Once I have the parsed RSS I call the function makeToolbar like this:

    UiApplication.getUiApplication().invokeLater(new Runnable(){ public void run(){makeToolbar();}});
    

    below the makeToolbar code:

    Just to give you an update on that. The delays were due to the multiple write debug messages to a file. I created a class to manage debug logs and that fixes the problem.

  • I can not display all images downloaded from the internet on Windows 7

    OK, so I just Windows 7.  I am trying to save documents that my teachers put up online in the form of a pdf file.  However when I try to open them I recorded them in Picasa it appears as a black box, saying "invalid Image".  In the Photo Viewer Windows it says "Could not be opened because the file format is not supported or you do not have the latest updates for the Windows Photo Viewer."  But I installed the latest version, as well as the latest Picasa.

    Also, I'm fully able to open other images (the ones I imported out of my phone etc.)

    What is the problem?

    Thanks in advance!

    PDF is not a picture itself, but you need a PDF reader to open them. Either try
    www.Adobe.com (Adobe Reader - do not add extra) or try
    Good alternative to Adobe Reader is Foxit

    http://www.foxitsoftware.com/PDF/reader/Reader3.php

    I hope this helps.

  • Image downloaded from stock


    Hello, I downloaded and bought a picture on my desk but can't find it, Suggestions? I recorded it in my library, but how do I re-record it somewhere that I can find? Thank you!!

    Hi lyndsayb12186670,

    Please visit the following link: I bought a stock image and I can't seem to upload the image under a license without the watermark? Please help

    Kind regards

    Tanuj

  • Is it possible to save files on server from Adobe as a PDF file or must it saved on the server of the client?

    The application has a custom navigation that opens PDF files within the app currently, that files are stored on the server of the client, but the client wants to store files on the server from Adobe. Is this possible?

    Not directly through a DPS Server. You may be able to store in creative cloud and then use a sharing URL, well I'm not sure CC operating conditions allowed that.

    It is preferable that the client stores the files on their server.

    Neil

  • Is it possible to get an image created from a placeholder to behave like a normal image?

    Hello

    I created some slides contained masters to use as models in my project. These Masters contained slides have the place for captions, images and smart forms holders.   When later to replace these mounts for real legends, images and active forms in the film strip, I want to consolidate some of these "real" objects  For some reason, I can't do that.   I can only group objects together in the film that are not in the slides of masters place holders.

    Does anyone have a solution for this problem?

    You can't do it. The only option is to not use a model of slides to the slide where you want to have grouped objects. Just use a blank slide and add your items.

  • I'm trying to image download from a Sony mavica camera using the disk and nothing is displayed. Is there a file I need to download? __

    How can I upload photos using an a Sony Mavica Floppy? I tried to use the file and nothing came up... help

    How can I upload photos using an a Sony Mavica Floppy? I tried to use the file and nothing came up... help

    ===============================
    I used to have a Mavica and after insertion
    the floppy drive... I want to go... My computer and
    the reader has to view the photos, click left.

    The following forum might be useful:

    Exchanging information Mavicahttp://forums.mavican.org/viewforum.php?f=16 John Inzer - MS - MVP - Digital Media Experience

  • How to save an Image on a Sql database without losing the Vision Info?

    Hello

    is it possible to save an image with the info of the vision in a Sql Server 2005 database? I tried the method of ImagetoArray and saved table in a varbinary field, but the info of the vision is lost.

    Kumi-

    You can do something like this (assuming that you already have the Image):

    imageString of object = null;
    CWIMAQFlattenOptions options = new CWIMAQFlattenOptions();
    Options. Type = CWIMAQFlattenTypes.cwimaqFlattenTypeImageAndVisionInfo;
    axCWIMAQVision1.FlattenImage (Image, options, imageString Ref);
    Byte [] imageData = imageString (byte []);

    and then imageData will hold the content of the image.  You can pass this to CWIMAQVision.UnflattenImage () to restore the data.

    Greg Stoll

    Vision R & D

    National Instruments

Maybe you are looking for