Thursday, 30 June 2016

Java Tutorial : Java Exception handling (Try with resources-custom AutoClosable implementation)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=TQba1G_Pkr4&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Exception handling (Try with resources-custom AutoClosable implementation) 
Java Tutorial : Java Exception handling (Try with resources-custom AutoClosable implementation) 

MyBufferedReader.java
public class MyBufferedReader implements AutoCloseable
{

    public void read()
    {
        System.out.println("read method is called...");
    }

    @Override
    public void close() throws Exception
    {
        System.out.println("close method is called...");
    }

}

TryWithResourcesDemo.java
public class TryWithResourcesDemo
{

    public static void main(String[] args) throws Exception
    {
        try (MyBufferedReader myBufferedReader = new MyBufferedReader())
        {
            myBufferedReader.read();
        }
    }

}
Output
read method is called...
close method is called...
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/ExceptionDemo_Custom_AutoClosable_impl_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4babce59a384cb4ab41f12b03cd7d11227a4b186/BasicJava/ExceptionDemo_Custom_AutoClosable_impl_App/?at=master

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment