DataInputStream和DataOutputStream实例

作者在 2010-05-21 15:05:12 发布以下内容
import java.io.*;
public class Test{
    public static void main(String args[]){
        try{
            FileOutputStream fos;
            DataOutputStream dos;
            FileInputStream fis;
            DataInputStream dis;
            fos = new FileOutputStream("myfile.data");
            dos = new DataOutputStream(fos);
            dos.writeUTF("休.格兰特");
            dos.writeInt(40);
            dos.close();
            fis = new FileInputStream("myfile.data");
            dis = new DataInputStream(fis);
            System.out.println("name:" + dis.readUTF());
            System.out.println("age:" + dis.readInt());
            fis.close();
        }catch(IOException e){
            System.out.println(e);    
        }
    }
}
I/O编 | 阅读 1069 次
文章评论,共0条
游客请输入验证码
浏览290920次