小编Ben*_*kin的帖子

FileNotFound尝试在1,000,000英寸的文本文件中查找重击手

我试图在1,000,000英寸的文本文件中找到重击手.

出于某种原因,当我运行它时,永远不会找到该文件.

我不明白我做错了什么,所以任何帮助都是最好的.

我相信我的整个程序的代码是正确的,除了它找不到文件的事实.

public class HH1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int k = 100;
        int count = 0;
        ArrayList<Integer> intList = new ArrayList<Integer>();
        File file = null;
        Scanner s = null;

        try {
            file = new File("IT179ProjectData.txt");
            s = new Scanner(file);
        } catch (Exception e) {
            System.out.println("Error");
            System.exit(0);
        }

        //Taking values from text file and inserting into an array list 
        while (s.hasNext()) {
            intList.add(s.nextInt());

        } …
Run Code Online (Sandbox Code Playgroud)

java arrays file arraylist try-catch

-1
推荐指数
1
解决办法
60
查看次数

标签 统计

arraylist ×1

arrays ×1

file ×1

java ×1

try-catch ×1