I want to populate the String[] array in main() function via the command line arguments. All the Strings are already written into a text file which I am passing to it using the ‘<‘ operator at runtime such as–>
java Sort < input.txt
all the Strings are contained inside the file input.txt (which needs to be sorted)—>
zzz bbb ggg aaa fff kkk lll
But this is not happening. I know it can easily be done using java.io but I need this easier way..
So more generally, you want to turn the contents of a file into the arguments to a program?
cat input.txt | xargs java Sort