SequenceInputStream close Example
SequenceInputStream class close example. This example shows you how to use close method.
SequenceInputStream class close example. public void close() throws IOException Closes this input stream and releases any system resources associated with the stream. A closed SequenceInputStream cannot perform input operations and cannot be reopened.
Here is the code
/**
* @ # Close.java
* A class reprsenting use to close method
* of SequenceInputStream class in java.io package
* version 09 June 2008
* author Rose India
*/
import java.io.*;
public class Close {
public static void main(String args[]) throws Exception {
String s = "Rose";
String s1 = "India";
byte[] b = s.getBytes();
byte[] b1 = s1.getBytes();
ByteArrayInputStream inputStream1 = new ByteArrayInputStream(b);
ByteArrayInputStream inputStream2 = new ByteArrayInputStream(b1);
SequenceInputStream siStream = new SequenceInputStream(inputStream1, inputStream2);
int i = 0;
while (true) {
int ch = siStream.read();
if (ch == -1) {
break;
}
{
System.out.print((char) ch);
}
}
siStream.close();
}
} |
|