Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从命令行读取文件时出现数组越界异常。JAVA_Java_Exception - Fatal编程技术网

从命令行读取文件时出现数组越界异常。JAVA

从命令行读取文件时出现数组越界异常。JAVA,java,exception,Java,Exception,因此,我试图在java中读取一个文件,如逐行,并将其与另一个文件中的所有单词进行比较,看看有多少单词匹配 public static void main(String[] args) { int i = 0; int wordFound = 0; String wordCheck; File file = new File("wordlist.txt"); File input = new File(args[0]); Boolean se

因此,我试图在java中读取一个文件,如逐行,并将其与另一个文件中的所有单词进行比较,看看有多少单词匹配

    public static void main(String[] args) {
    int i = 0;
    int wordFound = 0;
    String wordCheck;
    File file = new File("wordlist.txt");
    File input = new File(args[0]);
    Boolean searchResult;
无论哪种方式,这都是我的主文件,我只是尝试将args[0]设置为文件名

我正在这样运行我的程序: ? java拼写检查器>input.txt

所以我猜可能是args[2],但我试过了,我仍然得到ArrayIndexOutOfBoundsException,无论何时我在里面使用任何数字

我将感谢任何帮助


谢谢

按照您的方式,
java拼写检查器>input.txt
意味着您程序的所有输出都将用
input.txt
编写。这意味着,如果您进行任何类型的打印,它将被写入
input.txt


您需要的命令是
java SpellChecker input.txt

尝试从命令行参数中删除