标签:fileinput int rgs 目的 bis pac 数据类型 public oid
package com.study02;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
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 shujuliu {
public static void main(String[] args) throws IOException {
write();
read();
}
public static void read() throws IOException {
//数据源
FileInputStream fis = new FileInputStream("f.txt");
//缓冲流
BufferedInputStream bis = new BufferedInputStream(fis);
//处理流
DataInputStream dis = new DataInputStream(bis);
// 等同于 DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream("")));
//操作,读取了顺序要完全一致
System.out.println(dis.readUTF());
System.out.println(dis.read());
System.out.println(dis.readDouble());
dis.close();
}
public static void write() throws IOException {
//目的地
FileOutputStream fos = new FileOutputStream("f.txt");
//缓冲流
BufferedOutputStream bos = new BufferedOutputStream(fos);
//数据流:增加对Java基本数据类型和string类型的处理
DataOutputStream dos =new DataOutputStream(bos);
//写入数据
dos.writeUTF("aaaaaaaaa");
dos.write(11111);
dos.writeDouble(1111111111);
dos.flush();
dos.close();
}
}
标签:fileinput int rgs 目的 bis pac 数据类型 public oid
原文地址:https://www.cnblogs.com/LuJunlong/p/11831062.html