Solved

try and catch ...

Posted on 2006-06-14
3
204 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java SE 8u111  Lot of stuff broke 11 69
table example 4 29
Windows 10 IE Certificate Issue 10 47
hibernate example issues from command prompt 10 42
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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

803 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