我无法让我的文件在我的程序中读取... 为什么程序找不到该文件?我没有正确导入文件吗?
非常感谢任何反馈!谢谢
import java.util.Scanner;
import java.io.*;
public class ArraysIO {
public static void main(String[] args) throws IOException {
//local variables
//create array
String[] data = new String[100];
//set up counter
int count = 0;
// Create File and Scanner objects inside main
File file = new File("sampledata1.txt");
Scanner inputFile = new Scanner(file);
// Read in the names from the file
while (inputFile.hasNext() && count < data.length) {
data[count] = inputFile.nextLine();
count++;
}
// Remember to close the file ASAP
inputFile.close();
// TODO Auto-generated method stub
}
}