DataStream_操作基本类型数据的流对象

时间:2024-01-02 20:32:55
 import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; public class Test {
public static void main(String[] args) throws IOException {
writeData();
readData();
}
public static void readData() throws IOException { DataInputStream dis = new DataInputStream(new FileInputStream("F:\\IO\\data.txt")); String str = dis.readUTF(); System.out.println(str);
} public static void writeData() throws IOException { DataOutputStream dos = new DataOutputStream(new FileOutputStream("F:\\IO\\data.txt")); dos.writeUTF("你好"); dos.close();
}
}