OutputStream Write2() Example

Writes len bytes from the specified byte array starting at offset off to this output stream.


OutputStream class Write2() method example. This example shows you how to use Write2() method.This method Writes len bytes from the specified byte array starting at offset off to this output stream.

Here is the code:-

/**
 * @Program that  Writes len bytes from the specified byte array starting at 
    offset off to this output stream.
 * Write2.java 
 * Author:-RoseIndia Team
 * Date:-06-Jun-2008
 */
import java.io.*;

public class Write2 extends OutputStream {

    public void write(int ithrows IOException {
    }

    public static void main(String[] argsthrows Exception {
        //creating outputstream object
        OutputStream c = new PipedOutputStream();
        //creating inputstream object
        PipedInputStream pis = new PipedInputStream();
        //Connecting to the outputStream
        pis.connect((PipedOutputStreamc);
        byte[] b = {12345};
       //  Writes len bytes from the specified byte array starting at offset 
        c.write(b, 2, b.length-2);
        System.out.println("Stream before closing is");
        while (pis.available() != 0) {
            System.out.println(pis.read());
        }
        // Closes this output stream
        c.close();
        System.out.println("Stream after closing is");
        System.out.print(pis.read());
    }
}

Output of the Program
 Stream before closing is
3
4
5
Stream after closing is
-1

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

HOME | COPYRIGHT | CONTACT US