Thursday 1 September 2016

Java Tutorial : Java IO (SequenceInputStream)


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

Click the below Image to Enlarge
Java Tutorial : Java IO (SequenceInputStream) 
Java Tutorial : Java IO (SequenceInputStream) 
Java Tutorial : Java IO (SequenceInputStream) 
Refer: 
https://docs.oracle.com/javase/8/docs/api/index.html?java/io/SequenceInputStream.html

myfile1.txt
Peter is going to India,Join is going to India,
myfile2.txt
Welcome to America,Welcome to India
SequenceInputStreamDemo.java
import java.io.FileInputStream;
import java.io.IOException;
import java.io.SequenceInputStream;

public class SequenceInputStreamDemo
{

    public static void main(String[] args) throws IOException
    {
        FileInputStream fileInputStream1 = null;
        FileInputStream fileInputStream2 = null;
        SequenceInputStream sequenceInputStream = null;

        try
        {
            fileInputStream1 = new FileInputStream("myfile1.txt");
            fileInputStream2 = new FileInputStream("myfile2.txt");

            sequenceInputStream = new SequenceInputStream(fileInputStream1,
                                                              fileInputStream2);
            int i;
            while ((i = sequenceInputStream.read()) != -1)
            {
                System.out.print((char) i);
            }
        }
        finally
        {
            if(fileInputStream1!=null)
            {
                fileInputStream1.close();
            }
            if(fileInputStream2!=null)
            {
                fileInputStream2.close();
            }
            if(sequenceInputStream!=null)
            {
                sequenceInputStream.close();
            }
        }
    }

}
Output
Peter is going to India,Join is going to India,Welcome to America,Welcome to India
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_SequenceInputStream_Intro_App.zip?attredirects=0&d=1

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d261aab7f0b47dd247e532c02763fe1d7053f5d3/BasicJava/JavaIODemo_SequenceInputStream_Intro_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
  • Kids Tutorial
  • No comments:

    Post a Comment