Access an encoded image through an input stream

  1. Import the required classes.
    import java.io.InputStream;
  2. Save the image to the project folder or sub-folder.
  3. Add the image to the project in the BlackBerry® Java® Plug-in Eclipse® or the BlackBerry® Java® Development Environment.
  4. Invoke getClass().getResourceAsStream() to retrieve the image as an input stream of bytes.
    private InputStream input; 
    ... 
    Class _class = this.getClass();
    input = _class.getResourceAsStream("/images/example.png");
Next topic: Encode an image
Previous topic: Using encoded images

Was this information helpful? Send us your comments.