Jump to content

call stack.

- - - - -

  • Please log in to reply
No replies to this topic

#1
javaman

javaman

    Newbie

  • Members
  • PipPip
  • 12 posts
hi, looking at this example code:


public void writeList() {

    PrintWriter out = null;


    try {

        System.out.println("Entering try statement");

        out = new PrintWriter(

	                  new FileWriter("OutFile.txt"));

            for (int i = 0; i < SIZE; i++)

                out.println("Value at: " + i + " = " 

                             + vector.elementAt(i));

		  

    } catch (ArrayIndexOutOfBoundsException e) {

         System.err.println("Caught " 

                     + "ArrayIndexOutOfBoundsException: " 

                     +   e.getMessage());

				 

    } catch (IOException e) {

         System.err.println("Caught IOException: " 

                             +  e.getMessage());

				 

    } finally {

         if (out != null) {

             System.out.println("Closing PrintWriter");

             out.close();

		

         } 

         else {

             System.out.println("PrintWriter not open");

         }

     }

}


if say, for example, FileWriter() throws an IOException.
Am i write to say that the call stack will be:
FileWriter()
PrintWriter()
WriteList()

i.e the runtime will check for the handler in FilerWriter(), then PrintWriter(), and finally in WriteList()

regards,




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users