DataInputStream Read2() Example

Reads up to len bytes of data from the contained input stream


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

Here is the code:-

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

public class Read2 {

    public static void main(String[] argsthrows IOException {
        byte[] b = {123456};
        FileOutputStream fos = new FileOutputStream("Linux.txt");
        DataOutputStream dos = new DataOutputStream(fos);
        dos.write(b);
        dos.flush();
        dos.close();
        FileInputStream fis = new FileInputStream("Linux.txt");
        DataInputStream dis = new DataInputStream(fis);
        int l = dis.read(b, 0, b.length - 1);
        System.out.println("Bytes from the contained input stream is :" + l);

    }
}

Output of the Program
 Bytes from the contained input stream is :5

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

HOME | COPYRIGHT | CONTACT US