首页 > 代码库 > DataInputStream&DataOutputStream---操作基本类型值的流

DataInputStream&DataOutputStream---操作基本类型值的流

DataInputStream&DataOutputStream是一个基本的装饰类

import java.io.DataInputStream;import java.io.DataOutputStream;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;public class DataStreamDemo {    public static void main(String[] args) throws IOException {        //        writeData();                readData();            }    public static void readData() throws IOException {                //是一个基本的装饰类        FileInputStream fis= new FileInputStream("tempfile\\data.txt");        DataInputStream dis = new DataInputStream(fis);        boolean b = dis.readBoolean();        System.out.println(b);                dis.close();            }    public static void writeData() throws IOException {                //写入一些基本数据值,存储到文件中        FileOutputStream fos = new FileOutputStream("tempfile\\data.txt");        DataOutputStream dos = new DataOutputStream(fos);                        dos.writeBoolean(true);                dos.close();            }}

 

DataInputStream&DataOutputStream---操作基本类型值的流