Thursday, 30 June 2016

Java Tutorial : Java Exception handling (Try with resources using multiple resources)


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

Click the below Image to Enlarge
Java Tutorial : Java Exception handling (Try with resources using multiple resources) 
TryWithResourcesDemo.java
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class TryWithResourcesDemo
{

    public static void main(String[] args) throws IOException
    {
        try (FileInputStream fileInputStream = new FileInputStream(
                "myfile.txt");
                BufferedInputStream bufferedInputStream = new BufferedInputStream(
                        fileInputStream))
        {
            int data = bufferedInputStream.read();
            while (data != -1)
            {
                System.out.print((char) data);
                data = bufferedInputStream.read();
            }
        }

    }

}
Output
Peter
David
Julia
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/ExceptionDemo_try_with_resources_multi_App.zip?attredirects=0&d=1

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4babce59a384cb4ab41f12b03cd7d11227a4b186/BasicJava/ExceptionDemo_try_with_resources_multi_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