Many commands in Linux take input one of two ways, stdin, or as an argument to a file. Examples
echo "text from stdin" | lpr
lpr filename.txt
echo "text from stdin" | nl
nl filename.txt
The same is true with awk, sed, grep, and many others. How can the same behavior happen from a command line app written in Java? I believe System.in represents stdin. Reading stdin is not difficult. Reading from a file is not difficult, but how can the app act accordingly to how it was called on the command line?