这应该很简单,但出于某种原因,我无法从 file子档案和产出中提出论点。 我的守则如下:
public class Lab2 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args)
{
Lab2_CLA.Lab2_CLA(args);
}
}
public class Lab2_CLA {
public static void Lab2_CLA(String[] data)
{
System.out.printf("%s, %s: %s%n", data[1], data[0], data[2]);
}
}
我汇编了该守则,如果我通过终点站提出其论点的话,该守则是行之有效的。 注
《java lab2/Lab2 John Doe 12345678
印刷:Doe, John: 12345678
However, how can I get it to read data from a .txt file by typing the following into the terminal: "java lab2/Lab2 < input.txt"? Whenever I do this, I get the following error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at lab2.Lab2_CLA.Lab2_CLA(Lab2_CLA.java:12)
at lab2.Lab2.main(Lab2.java:34)