[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Creating Images - JavaME

Posted on 2011-02-10
4
Medium Priority
?
406 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month20 days, 1 hour left to enroll

873 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