How do you process information in Java that was input from a file. For Example: suppose you have a file input.txt. The contents of this file is: abcdefghizzzzjklmnop azzbcdefghijklmnop
My hope would be that the information would be put into the argument array of strings such that the following code would output "abcdefghizzzzjklmnop"
class Test {
public static void main(String[] args) {
System.out.println(args[0]);
}
}
The command I have been using throws an array out of bound exception. This command is:
java Test < input.txt
Non-file based arguments work fine though. ie. java Test hello,a nd java Test < input.txt hello.
More information: I have tried putting the file contents all on one line to see if \n \r characters may be messing things up. That didn't seem to help.
Also, I can't use the bufferedreader class for this because this is for a program for school, and it has to work with my professors shell script. He went over this during class, but I didn't write it down (or I can't find it).
Any help?