package io2;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Demo4 {
// DataInputStream 对基本的输入流(InputStream)
// 功能扩展,提供基本类型的输入方法
public static void main(String[] args) throws IOException {
//缓冲流(Buffer),处理流 (DataInputStream)都是底层依赖
//FileInputStream(file)节点流; 在构造方法(new 节点流)
// 输出流
DataOutputStream out = new
DataOutputStream(new FileOutputStream("src/test3.txt"));
DataInputStream in = new
DataInputStream(new FileInputStream("src/test3.txt"));
// Data流扩展了流对基本数据类型操作的功能
out.writeInt(6);
out.writeInt(-6);
out.writeLong(16L);
out.writeDouble(12.9);
out.writeUTF("中国");
out.flush(); out.close();
IOUtils.printInput("src/test3.txt");
int num1 = in.readInt();
int num2 = in.readInt();
long num3 = in.readLong();
double num4 = in.readDouble();
String str = in.readUTF();
System.out.println(num1+" , "+num2+" , "+
num3+" , "+ num4 +" ,"+str);
}
}
阅读(802) | 评论(0) | 转发(0) |