Solved

try and catch ...

Posted on 2006-06-14
3
202 Views
Last Modified: 2010-03-31
Hello experts,

   I failed to put try catch for the IOEXCEPTION for in.readLine ... because I already have a tray-catch inside the while loop ... is there a way to solve this problem ? thanks.


  while ((str = in.readLine()) != null) {
     try {
     } catch {
     }

  }
0
Comment
Question by:meow00
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 16907522
its the readLine() method that throws the exception so the try catch needs to go around that line

  try {

   while ((str = in.readLine()) != null) {
       try {
       } catch (Exception ex) {
       }
    }

   } catch (IOException ex) {
       ex.printStackTrace();
   }
0
 
LVL 1

Author Comment

by:meow00
ID: 16907539
so ...  it is legal to have nested try-catch ???
0
 
LVL 92

Accepted Solution

by:
objects earned 350 total points
ID: 16907551
yes
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

707 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

17 Experts available now in Live!

Get 1:1 Help Now