问题描述
练习JavaI/O时自己试着写demo,当使用RandomAccessFile的readUTF()方法时报java.io.EOFException。源码如下:
DirList.java
package com.star.io;
import java.io.IOException;
import java.io.RandomAccessFile;
public class DirList {
static String file= "G://a.txt";
static void testRAF() throws IOException {
RandomAccessFile rf=new RandomAccessFile(file,"r");
System.out.println(rf.readLine());