SequenceInputStream read Example

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


SequenceInputStream class read example. 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.

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 Read {

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

        while (true) {
            int ch = siStream.read();
            if (ch == -1) {
                break;
            }
            {
                System.out.print((charch);
            }
        }
        siStream.close();
    }
}

Output
RoseIndia

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

HOME | COPYRIGHT | CONTACT US