我正在尝试用 Java 读取一个名为“KFormLList.txt”的文件。它与该程序一起保存在默认包中,但是当我尝试运行它时,我收到以下错误消息:“错误:KFormLList.txt(系统找不到指定的文件)”
我究竟做错了什么?谢谢你的帮助。
import java.io.*;
public class VLOCGenerater {
/**
* @param args
*/
public static void main(String[] args) {
try {
//Read the text file "KFormLList.txt"
FileInputStream fis = new FileInputStream("KFormLList.txt");
DataInputStream dis = new DataInputStream(fis);
BufferedReader br = new BufferedReader(new InputStreamReader(dis));
String strLine;
int V = 0;
int LOC = 0;
while((strLine = br.readLine())!= null ){
if (strLine.trim().length() != 0){
System.out.println(strLine);
V++;
}
else {
LOC++;
}
}
System.out.println("V = " + V);
System.out.println("LOC = " + LOC);
dis.close();
}
catch (Exception e){
System.err.println("Error: " + e.getMessage());
}
}
}