Java IO Tutorial - Java SequenceInputStream.close()








Syntax

SequenceInputStream.close() has the following syntax.

public void close()  throws IOException

Example

In the following code shows how to use SequenceInputStream.close() method.

import java.io.FileInputStream;
import java.io.IOException;
import java.io.SequenceInputStream;
//  w  ww. jav a  2  s  .  c  o m
public class Main {
  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;
      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();
  }
}