System.out.print(dis.readUTF());报错
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class DateStream {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
FileOutputStream fs=new FileOutputStream("word.text");
DataOutputStream ds=new DataOutputStream(fs);
ds.writeUTF("使用writeUTF()方法写入数据");//使用utf—8编码写出
ds.writeChars("使用writechars()方法写入数据");//使用utf—16编码写出
ds.writeBytes("使用writebytes()方法写入数据");
ds.close();
FileInputStream fis=new FileInputStream("word.txt");
DataInputStream dis=new DataInputStream(fis);
fis.close();
dis.close();
}
}
Exception in thread "main" java.io.EOFException
at java.io.DataInputStream.readFully(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at DateStream.main(DateStream.java:25)