DataInputStream, DataOutputStream
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
class DOSDISDemo {
public static void main(String[] args) throws Exception {
DataOutputStream dos = null;
FileOutputStream fos = new FileOutputStream("data.dat");
dos = new DataOutputStream(fos);
dos.writeInt(256);
dos.writeDouble(Math.PI);
dos.writeUTF("Java");
DataInputStream dis = null;
FileInputStream fis = new FileInputStream("data.dat");
dis = new DataInputStream(fis);
System.out.println(dis.readInt());
System.out.println(dis.readDouble());
System.out.println(dis.readUTF());
}
}
Related examples in the same category