import java.io.*; 
public class Example8_9 { 
public static void main(String args[]) { 
try {   
        FileOutputStream fos=new FileOutputStream("jerry.dat"); 
        DataOutputStream outData=new DataOutputStream(fos); 
        outData.writeInt(100); 
        outData.writeLong(123456);   
        outData.writeFloat(3.1415926f); 
        outData.writeDouble(987654321.1234); 
        outData.writeBoolean(true); 
        outData.writeChars("i am ookk"); 
       }  
       catch(IOException e){
} 
       try {      
         FileInputStream fis=new FileInputStream("jerry.dat"); 
        DataInputStream inData=new DataInputStream(fis); 
        System.out.println(inData.readInt());                 //读取int数据 
        System.out.println(inData.readLong());               //读取long数据  
        System.out.println(inData.readFloat());               //读取float数据 
        System.out.println(inData.readDouble());             //读取double数据 
        System.out.println(inData.readBoolean());            //读取boolean数据 
        char c; 
        while((c=inData.readChar())!='\0'){                 //'\0'表示空字符。 
            System.out.print(c); 
        }  
        catch(IOException e){
} 
    } 
}
