SequenceInputStream read Example

SequenceInputStream class read example. This example shows you how to use read method.


SequenceInputStream class read example. public int read(byte[] , int , int ) throws IOException Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until at least 1 byte of input is available; otherwise, no bytes are read and 0 is returned.

Here is the code

/**
 * @ # Read.java
 * A class reprsenting use to read method 
 * of SequenceInputStream class in java.io package
 * version 09 June 2008
 * author Rose India 
 */
import java.io.*;

public class Read1 {

    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);

        System.out.println(siStream.read(b, 0, b.length));
        siStream.close();
    }
}

Output
4

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US