InputStream Read1() Example

Reads up to len bytes of data from the input stream into an array of bytes.


InputStreamclass Read1() method example. This example shows you how to use Read1() method.This method Reads up to len bytes of data from the input stream into an array of bytes.

Here is the code:-

/**
 * @Program that Reads up to len bytes of data from the input stream into an 
 * array of bytes.
 * Read1.java 
 * Author:-RoseIndia Team
 * Date:-06-Jun-2008
 */
import java.io.*;

public class Read1 extends InputStream {

    public int read() throws IOException {
        return 0;
    }

    public static void main(String[] argsthrows IOException {
        PipedInputStream i = new PipedInputStream();
        PipedOutputStream o = new PipedOutputStream();
        i.connect(o);
        byte[] b = {12345};
        o.write(b);
  System.out.print("The estimate of the number of bytes that can be read : ");
        while (i.available() != 0) {
  //Reads up to len bytes of data from the input stream into an array of bytes.
            System.out.print(" " + i.read(b,1,b.length-1));
        }
        i.close();
    }
}

Output of the Program
 The estimate of the number of bytes that can be read :  4 1

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

HOME | COPYRIGHT | CONTACT US