I have my program saved in JAR format. I need to read data from two different files given by user using this line: java -jar app.jar file1.txt file2.txt
. How can I read it? I wrote this:
Scanner scan = new Scanner(System.in);
String inputFileName1 = scan.next().trim();
String inputFileName2 = scan.next().trim();
File input1 = new File(inputFileName1);
Scanner file1 = new Scanner(input1);
File input2 = new File(inputFileName2);
Scanner file2 = new Scanner(input2);
It works when I manually write: file1.txt file2.txt, but not with the command line. What's wrong?