Heres my basic goal: Convert a program that uses a Scanner and the keyboard as input into a program that uses the Scanner and java args as input. This will be done programatically for a variety of programs, so I'd like to make as few and as small changes to the actual program itself. I'm able to do this by changing Scanner scanner = new Scanner(System.in); into Scanner scanner = new Scanner(args[0]);.
Now I can seperate each argument with a space in args[0] and the program runs fine, but ONLY if it doesn't use scanner.nextLine(). As soon as scanner.nextLine() is used, the scanner munches up the entire String and breaks the program.
I can't figure out a workaround without changing the program structure all together (Removing all the scanner.nextLine()s. Is there maybe some sort of character/sequence that will stop scanner.nextLine(), or will it always process the entire String?
Thanks
Edit: My initial idea was to give the scanner a String array and have it go through that, index by index, regardless of which method was used (next, nextInt, nextLine). Is that perhaps possible?