java.io

Class SequenceInputStream

Implemented Interfaces:
Closeable

public class SequenceInputStream
extends InputStream

A SequenceInputStream represents the logical concatenation of other input streams. It starts out with an ordered collection of input streams and reads from the first one until end of file is reached, whereupon it reads from the second one, and so on, until end of file is reached on the last of the contained input streams.
Since:
JDK1.0

Constructor Summary

SequenceInputStream(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.

Method Summary

int
available()
Returns the number of bytes available on the current 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(b[] , int off, int len)
Reads up to len bytes of data from this input stream into an array of bytes.

Methods inherited from class java.io.InputStream

available, close, mark, markSupported, read, read, read, reset, skip

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

SequenceInputStream

public SequenceInputStream(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. The input streams that are produced by the enumeration will be read, in order, to provide the bytes to be read from this SequenceInputStream. After each input stream from the enumeration is exhausted, it is closed by calling its close method.
Parameters:
e - an enumeration of input streams.
See Also:
Enumeration
Usages and Demos :

View More Examples of SequenceInputStream(InputStream> e)
   1: 
   2:         SequenceInputStream s = new SequenceInputStream(mylist);
   3:         int c;
   4: 
   5:         while ((c = s.read()) != -1)

View Full Code Here
   1:         FileFilter fFilter = new FileFilter("D:\Java2\Source","java");
   2:         SequenceInputStream seqInput = new SequenceInputStream(fFilter);
   3:         FileOutputStream fOutput = new FileOutputStream("SourceSum");
   4:         int bContent;
   5:         while((bContent = seqInput.read())!=-1)

View Full Code Here
   1:          {
   2:          final InputStream is = new SequenceInputStream(Collections.enumeration(outputList));
   3:          final AudioInputStream ais = new AudioInputStream(is, currentFormat, totBytes / currentFormat.getFrameSize());
   4:          AudioSystem.write(ais, outputType, byteArrayOutputStream);
   5:          }

View Full Code Here
   1:         File file = new File(baseName);
   2:         InputStream is = new SequenceInputStream(outputList.elements());
   3:         AudioInputStream ais = new AudioInputStream(is,
   4:             currentFormat, totBytes / currentFormat.getFrameSize());
   5:             if (false) {

View Full Code Here
   1:         InputStream seqStream = 
   2:             new SequenceInputStream(streamVec.elements());
   3:         InputStream infStream =
   4:             new InflaterInputStream(seqStream, new Inflater());
   5:         dataStream = new DataInputStream(infStream);

View Full Code Here

SequenceInputStream

public 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.
Parameters:
s1 - the first input stream to read.
s2 - the second input stream to read.
Usages and Demos :

View More Examples of SequenceInputStream(InputStream s1,InputStream s2)
   1:     
   2:     SequenceInputStream sis = new SequenceInputStream( sbis, fis );
   3:     LineNumberInputStream lsis = new LineNumberInputStream( sis );
   4: 
   5:     System.out.print( "0: " );

View Full Code Here
   1:     
   2:     SequenceInputStream result = new SequenceInputStream(in1, in2);
   3:         ...
   4:     result = new SequenceInputStream(result, in3); 
   5:     return result;
   6:     
   7:   }

View Full Code Here
   1:       ByteArrayInputStream is2 = new ByteArrayInputStream(str2.getBytes());
   2:       SequenceInputStream sis = new SequenceInputStream(is1, is2);
   3: 
   4:         ...
   5:       ByteArrayInputStream is2 = new ByteArrayInputStream(str2.getBytes());
   6:       SequenceInputStream sis = new SequenceInputStream(is1, is2);
   7: 
   8:       sis.read(buf);
   9:       sis.close();

View Full Code Here
   1:             dataIn = data.getInputStream();
   2:             makeCryptoKey(new SequenceInputStream(metaIn, dataIn),
   3:                           meta.size() + data.size() );
   4:         ...
   5:             dataIn = data.getInputStream();
   6:             ret = super.encode(new SequenceInputStream(metaIn, dataIn),
   7:                                meta.size() + data.size(),
   8:                                meta.size(), ctBucket );
   9:         }

View Full Code Here
   1:                 if (sr != null) {
   2:                     in = new SequenceInputStream(in, sr.get(key));
   3:                 }
   4:             } catch (Exception e) {
   5:             }

View Full Code Here

Method Details

available

public int available()
            throws IOException
Returns the number of bytes available on the current stream.
Overrides:
available in interface InputStream
Since:
JDK1.1

close

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.

If this stream was created from an enumeration, all remaining elements are requested from the enumeration and closed before the close method returns. of InputStream .

Specified by:
close in interface Closeable
Overrides:
close in interface InputStream
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of close()
   1: 
   2:         SequenceInputStream s = new SequenceInputStream(mylist);
   3:         int c;
   4:         ...
   5: 
   6:         s.close();
   7:     }
   8: }

View Full Code Here
   1:         FileFilter fFilter = new FileFilter("D:\Java2\Source","java");
   2:         SequenceInputStream seqInput = new SequenceInputStream(fFilter);
   3:         FileOutputStream fOutput = new FileOutputStream("SourceSum");
   4:         ...
   5:         }
   6:         seqInput.close();
   7:         ...
   8:         fOutput.close();
   9:     }

View Full Code Here
   1: {
   2:   System.out.println("Started test of SequenceInputStream");
   3: 
   4:         ...
   5:       ByteArrayInputStream is2 = new ByteArrayInputStream(str2.getBytes());
   6:       SequenceInputStream sis = new SequenceInputStream(is1, is2);
   7: 
   8:         ...
   9: 
  10:       sis.close();
  11:       System.out.println("PASSED: Simple read test");
  12:         ...
  13:       sis.read(buf);
  14:       sis.close();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.SequenceInputStream;
   3: import java.io.UnsupportedEncodingException;
   4:         ...
   5:             signingPublicKey.writeBytes(fileOutputStream);
   6:             fileOutputStream.close();
   7:             fileOutputStream = null;
   8:         ...
   9:                 try {
  10:                     fileOutputStream.close();
  11:                 } catch (IOException ioe) {
  12:         ...
  13:                 try {
  14:                     fileInputStream.close();

View Full Code Here
   1: import java.io.PrintWriter;
   2: import java.io.SequenceInputStream;
   3: import java.io.StringReader;
   4:         ...
   5:                 MCRUtils.copyStream(bi, bo);
   6:                 bi.close();
   7:         ...
   8:                 bo.close();
   9:             } catch (FileNotFoundException fnfe) {
  10:         ...
  11:                         doc = getXMLAsJDOM(bis);
  12:                         bis.close();

View Full Code Here

read

public int read()
            throws IOException
Reads the next byte of data from this input stream. The byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

This method tries to read one character from the current substream. If it reaches the end of the stream, it calls the close method of the current substream and begins reading from the next substream.

Overrides:
read in interface InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of read()
   1: 
   2:         SequenceInputStream s = new SequenceInputStream(mylist);
   3:         int c;
   4:         ...
   5: 
   6:         while ((c = s.read()) != -1)
   7:            System.out.write(c);
   8: 
   9:         s.close();

View Full Code Here
   1:         FileFilter fFilter = new FileFilter("D:\Java2\Source","java");
   2:         SequenceInputStream seqInput = new SequenceInputStream(fFilter);
   3:         FileOutputStream fOutput = new FileOutputStream("SourceSum");
   4:         ...
   5:         int bContent;
   6:         while((bContent = seqInput.read())!=-1)
   7:         {
   8:             fOutput.write(nContent);
   9:         }

View Full Code Here

read

public int read(b[] ,
                int off,
                int len)
            throws IOException
Reads up to len bytes of data from this input stream into an array of bytes. This method blocks until at least 1 byte of input is available. If the first argument is null, up to len bytes are read and discarded.

The read method of SequenceInputStream tries to read the data from the current substream. If it fails to read any characters because the substream has reached the end of the stream, it calls the close method of the current substream and begins reading from the next substream.

Overrides:
read in interface InputStream
Parameters:
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
int the number of bytes read.
Throws:
IOException - if an I/O error occurs.