Solved

Creating Images - JavaME

Posted on 2011-02-10
4
398 Views
Last Modified: 2013-11-24
I am creating images using the following code..However, my app will stop after printing out STATEMENT 3 which means I can't use Image image = Image.createImage(input);

Is there anyway I can ctach this type of excpetion beside IOexception and Exception?
Does anyone have any idea? Thank in advance.

FileConnection filenames = (FileConnection)Connector.open(main_directory +  "testFolder" + "/"
                                                + imageName ,Connector.READ);
InputStream input = filenames.openInputStream();
try {
                                                Logger.logEventInfo("STATEMENT 3");
                                                Image image = Image.createImage(input);
                                                Logger.logEventInfo("READING: " + imageName +"\n");
                                                Logger.logEventInfo("STATEMENT 4");
                                                if(image != null){               
                                                      Logger.logEventInfo("STATEMENT 5");                                                
                                                }
                                                else continue;                                      
                                                Logger.logEventInfo("STATEMENT 7");
                                          }
                                          catch (IOException e) {
                                                Logger.logEventInfo("STATEMENT 8");                                                
                                                description = e.toString();
                                                Logger.logEventInfo("STATEMENT 9");
                                                Logger.logEventInfo("READING: " + imageName +"\n");
                                          } catch (Exception e)  {
                                                Logger.logEventInfo("STATEMENT 11");
                                                Exceptiondescription = e.toString();
                                                Logger.logEventInfo("STATEMENT 12");                                                
                                                updateContent("READING: " + imageName);      
                                                Logger.logEventInfo("READING: " + imageName +"\n");
                                                Logger.logEventInfo("STATEMENT 13");
                                          }                              
                                          Logger.logEventInfo("STATEMENT 14");
                                          input.close();
0
Comment
Question by:bbdriver
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Shura85
ID: 34875435
Can you show the code you use to get and configure the logger?  That might provide some insight into why it is throwing an error to begin with.  
0
 

Author Comment

by:bbdriver
ID: 34881364
I am not sure if it's about the logger cause some of other images are able to pass STATEMENT 3 and goes into either createimage or Exception. However, for some image, it was unable to go anywhere
0
 

Author Comment

by:bbdriver
ID: 34885007
What kind can I use to catch the exception beside IOException and Exception?
0
 
LVL 1

Accepted Solution

by:
Shura85 earned 500 total points
ID: 34888442
Exception is the mother of all java exceptions, so it should be catching any and all runtime exceptions this code throws.  However, Image.createImage also throws a NullPointerException - try catching that, and if it works, it probably means there is a scope issue with your image location.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now