public class StreamTest6 {
public static void main(String[] args) throws Exception{
DataOutputStream data = new DataOutputStream(new BufferedOutputStream(
new FileOutputStream("d.txt")));
char a ='d';
int b =9;
float d= 3.3f;
data.write(a);
data.write(b);
data.writeFloat(d);
data.close();
DataInputStream data2 = new DataInputStream(new BufferedInputStream
(new FileInputStream("d.txt")));
System.out.println(data2.readChar());
System.out.println(data2.readInt());
System.out.println(data2.readFloat());
data2.close();
}
}
明明读取和打印的顺序是一样的,为什么会出现乱码 并且有java.io.EOFException的错误呢? |