package Theirteen;
import java.io.*;
public class Text2 {
public static void main(String[] args) throws Exception{
try{
DataOutputStream Output = new DataOutputStream(new FileOutputStream("text.dat"));
Output.writeUTF("Jone");
Output.writeDouble(7.9);
Output.writeUTF("Jim");
Output.writeDouble(9.3);
Output.writeUTF("George");
Output.writeDouble(6.4);
}catch (Exception E){
System.out.println("Error");
}
try{
DataInputStream Input = new DataInputStream(new FileInputStream("text.dat"));
System.out.println(Input.readUTF() + " "+ Input.readDouble());
System.out.println(Input.readUTF() + " "+ Input.readDouble());
System.out.println(Input.readUTF() + " " +Input.readDouble());
}catch (Exception E){
E.printStackTrace();
}
}
}
【JAVA 日常练习】+ IO
最新推荐文章于 2024-07-22 16:07:42 发布