我写了一个程序,要求像这样的用户输入:
System.out.println("Where would you like the output file to end up? (full path and desired file name): ");
Scanner out_loc = new Scanner(System.in);
output_loc = out_loc.nextLine();
...
System.out.println("Hey, please write the full path of input file number " + i + "! ");
System.out.println("For example: /home/Stephanie/filein.txt");
Scanner fIn = new Scanner(System.in);
我以这种方式多次要求输入,但如果您输入错误,可能会非常痛苦,因为您必须终止程序并重新运行。当你运行一个程序时,有没有一种简单的方法可以一次输入所有内容?就像在运行时在命令行中声明它一样?
java -jar /home/Stephanie/NetBeansProjects/cBelow/dist/cBelow.jar -userinputhere?