DataInputStream ReadByte() Example

Reads some number of bytes from the contained input stream


DataInputStreamclass ReadByte() method example. This example shows you how to use ReadByte() method.This method Reads some number of bytes from the contained input stream

Here is the code:-

/**
 * @Program that Reads some number of bytes from the contained input stream
 * ReadByte.java 
 * Author:-RoseIndia Team
 * Date:-07-jun-2008
 */
import java.io.*;

public class ReadByte {

    public static void main(String[] argsthrows IOException {
        byte bB=34;
        FileOutputStream fos = new FileOutputStream("Linux.txt");
        DataOutputStream dos = new DataOutputStream(fos);
        dos.writeByte(bB);
        dos.flush();
        dos.close();
        FileInputStream fis = new FileInputStream("Linux.txt");
        DataInputStream dis = new DataInputStream(fis);
        //Reads some number of bytes from the contained input stream
        byte b=dis.readByte();
        System.out.println("Bytes from the contained input stream is: "+b);

    }
}

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

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

HOME | COPYRIGHT | CONTACT US