数据IO流

数据IO流
1.DataInputStream:数据字节输入流 
2.DataOutPutStream:数据字节输出

package file;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.junit.Test;

/*
 
数据IO流
 1.DataInputStream:数据字节输入流  
 2.DataOutPutStream:数据字节输出流
 
 
String name="zhang-shan";
int age=20;
String gender="female";
double balance=10000;

*/

public class test09 {
        
    @Test
    public void save() throws IOException {
        String name="zhang-shan";
        int age=20;
        char gender='f';
        double balance=10000;
        
        
        //1.创建IO流
        DataOutputStream dos=new DataOutputStream(new FileOutputStream("resource/game.txt"));
        
        //2.写数据
        dos.writeUTF(name);
        dos.writeInt(age);
        dos.writeChar(gender);
        dos.writeDouble(balance);
        
        //3.关闭
        dos.close();
    }

}

 

posted on 2020-06-05 16:04  happygril3  阅读(234)  评论(0)    收藏  举报

导航