Total members 11889 |It is currently Sun Apr 14, 2024 10:53 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





In java7 you can do multiple exception catching instead of adding many catches , for example imagine we have the following snippet in java6 :
java code
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ReadMyFile {

    public static void main(String args[]) {

        Connection oracleConnection = null;
        String filePath = "C://file.txt";
        try {
            File file = new File(filePath);
            FileInputStream fileInputStream = new FileInputStream(file);
            fileInputStream.read();
            oracleConnection = DriverManager.getConnection("dbURL", "dbUsername", "dbPass");
        } catch (SQLException ex) {
            Logger.getLogger(ReadMyFile.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException e) {
            e.printStackTrace();
        }



    }
}
 


At java7 it will be Multiple Exception Catching like this:
java code
      try {
            File file = new File(filePath);
            FileInputStream fileInputStream = new FileInputStream(file);
            fileInputStream.read();
            oracleConnection = DriverManager.getConnection("dbURL", "dbUsername", "dbPass");
        } catch (SQLException | IOException ex) {
            ex.printStackTrace();
        }

 




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Multiple Exception Catching
 Multiple Inheritance     -  
 Using Multiple Values for a Cookie in php     -  
 Jtable with multiple headings     -  
 Code to open multiple links.     -  
 send mail to Multiple recipients     -  
 calculate data from multiple selection     -  
 Out of Bounds exception     -  
 Exception handling     -  
 Exception is not clear     -  
 Javascript Validation On Multiple Select Lists     -  



Topic Tags

Java Exceptions
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com