Example usage for java.io SequenceInputStream read

List of usage examples for java.io SequenceInputStream read

Introduction

In this page you can find the example usage for java.io SequenceInputStream read.

Prototype

public int read() throws IOException 

Source Link

Document

Reads the next byte of data from this input stream.

Usage

From source file:Main.java

public static void main(String args[]) throws IOException {
    FileInputStream f1 = new FileInputStream("ByteArrayIOApp.java");
    FileInputStream f2 = new FileInputStream("FileIOApp.java");
    SequenceInputStream inStream = new SequenceInputStream(f1, f2);
    boolean eof = false;
    int byteCount = 0;
    while (!eof) {
        int c = inStream.read();
        if (c == -1)
            eof = true;/*from w  w w. ja v a2  s  . c  om*/
        else {
            System.out.print((char) c);
            ++byteCount;
        }
    }
    System.out.println(byteCount + " bytes were read");
    inStream.close();
    f1.close();
    f2.close();
}

From source file:Main.java

public static void main(String args[]) throws IOException {
    SequenceInputStream inStream;
    FileInputStream f1 = new FileInputStream("file1.java");
    FileInputStream f2 = new FileInputStream("file2.java");
    inStream = new SequenceInputStream(f1, f2);
    boolean eof = false;
    int byteCount = 0;
    while (!eof) {
        int c = inStream.read();
        if (c == -1)
            eof = true;/*from   w  ww . j a  v a 2  s .c om*/
        else {
            System.out.print((char) c);
            ++byteCount;
        }
    }
    System.out.println(byteCount + " bytes were read");
    inStream.close();
    f1.close();
    f2.close();
}

From source file:Main.java

public static void main(String args[]) throws IOException {
    SequenceInputStream inStream;
    FileInputStream f1 = new FileInputStream("ByteArrayIOApp.java");
    FileInputStream f2 = new FileInputStream("FileIOApp.java");
    inStream = new SequenceInputStream(f1, f2);
    boolean eof = false;
    int byteCount = 0;
    while (!eof) {
        int c = inStream.read();
        if (c == -1)
            eof = true;/*from   ww w. j  a v a  2s .  c  o m*/
        else {
            System.out.print((char) c);
            ++byteCount;
        }
    }
    System.out.println(byteCount + " bytes were read");
    inStream.close();
    f1.close();
    f2.close();
}

From source file:Main.java

public static void main(String args[]) throws IOException {
    SequenceInputStream inStream;
    FileInputStream f1 = new FileInputStream("ByteArrayIOApp.java");
    FileInputStream f2 = new FileInputStream("FileIOApp.java");
    inStream = new SequenceInputStream(f1, f2);
    boolean eof = false;
    int byteCount = 0;
    System.out.println(inStream.available());
    while (!eof) {
        int c = inStream.read();
        if (c == -1)
            eof = true;//from  w  w w .  j a v  a2s .c  o  m
        else {
            System.out.print((char) c);
            ++byteCount;
        }
    }
    System.out.println(inStream.available());
    System.out.println(byteCount + " bytes were read");
    inStream.close();
    f1.close();
    f2.close();
}