You don't need to. If a file has been redirected to your program and there's stuff in it, then System.in will have a handle it. If there's nothing in the System.in buffer, then you can assume no file has been passed to you.
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
It doesn't matter. Just write the program as if there's someone there typing. If input is coming from a pipe instead, then the prompts will be printed, but no-one will read them. They'll just be ignored.
Hi, I tried just the following code but do not work. I would like the program to skip the User input if file redirection is used. or skip file redirection and request for user input if command "java program" is used.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop