title: Linux command input done in Java
body: <p>Many commands in Linux take input one of two ways, stdin, or as an argument to a file. Examples</p>
  
  <p>echo "text from stdin" | lpr</p>
  
  <p>lpr filename.txt</p>
  
  <p>echo "text from stdin" | nl</p>
  
  <p>nl filename.txt</p>
  
  <p>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?</p>