Total members 11663 |It is currently Sat Sep 23, 2017 12:12 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();
        }

 





Author:
Mastermind
User avatar Posts: 2707
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     -  
 Exception is not clear     -  
 Out of Bounds exception     -  
 Exception handling     -  
 Need Help for Java Chat - one server multiple clients..     -  



Topic Tags

Java Exceptions







Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team