Sunday, August 2, 2009

The following code is used to connect to an external service and send it a message. If either of the connect(

The following code is used to connect to an external service and send it a message. If either of the connect() or send() methods fail, an exception of type Exception is thrown. Modify the code so that the functionality is the same but the Connection is always closed.





Connection c = new Connection();


c.connect(“service”);


c.send(“message”);


c.close();

The following code is used to connect to an external service and send it a message. If either of the connect(
If you are talkng about Java program, then the code will


Connection c = new Connection();


try


{


c.connect("service");


c.send("message");


}


catch( Exception e)


{


//report exception


}


finally


{


c.close();


}


No comments:

Post a Comment