DataOutputStream WriteInt() Example

Writes an int to the underlying output stream as four bytes, high byte first.


DataOutputStreamclass WriteInt() method example. This example shows you how to use WriteInt() method.This method Writes an int to the underlying output stream as four bytes, high byte first.

Here is the code:-
/**
 * @Program that Writes an int to the underlying output stream as four bytes,
    high byte first
 * WriteInt.java 
 * Author:-RoseIndia Team
 * Date:-09-jun-2008
 */
import java.io.*;
public class WriteInt {
public static void main(String[] args)throws IOException {
int f=23;
FileOutputStream fos=new FileOutputStream("g.txt");    
DataOutputStream dos=new DataOutputStream(fos);
//Writes an int to the underlying output stream as four bytes,high byte first
dos.writeInt(f);
FileInputStream fis=new FileInputStream("g.txt");    
DataInputStream dis=new DataInputStream(fis);
System.out.println("Int to the underlying output stream is : "+dis.readInt());
    }

}

Output of the Program
 Int to the underlying output stream is : 23

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

HOME | COPYRIGHT | CONTACT US