Example usage for java.io SequenceInputStream available

List of usage examples for java.io SequenceInputStream available

Introduction

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

Prototype

public int available() throws IOException 

Source Link

Document

Returns an estimate of the number of bytes that can be read (or skipped over) from the current underlying input stream without blocking by the next invocation of a method for the current underlying input stream.

Usage

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;/*  w  w w  .  j  av  a2 s.  co  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();
}