java.lang.Object | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | - | - | java.io.InputStream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | - | - | java.io.SequenceInputStream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A SequenceInputStream represents the logical concatenation of other input streams.
Constructor | Summary |
---|---|
SequenceInputStream(Enumeration<? extends InputStream> e) | Initializes a newly created SequenceInputStream by remembering the argument, which must be an Enumeration that produces objects whose run-time type is InputStream. |
SequenceInputStream(InputStream s1, InputStream s2) | Initializes a newly created SequenceInputStream by remembering the two arguments, which will be read in order, first s1 and then s2, to provide the bytes to be read from this SequenceInputStream. |
Return | Method | Summary |
---|---|---|
int | available() | 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. |
void | close() | Closes this input stream and releases any system resources associated with the stream. |
int | read() | Reads the next byte of data from this input stream. |
int | read(byte[] b, int off, int len) | Reads up to len bytes of data from this input stream into an array of bytes. |
import java.io.FileInputStream;
import java.io.IOException;
import java.io.SequenceInputStream;
public class Main {
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;
else {
System.out.print((char) c);
++byteCount;
}
}
System.out.println(byteCount + " bytes were read");
inStream.close();
f1.close();
f2.close();
}
}
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |