Clearing all remaining input in System.in
835847Nov 9 2011 — edited Nov 9 2011I am at a point in my program where I need to clear garbage out of System.in and I have tried several ways to do this.
When Scanner reads the garbage, an exception is thrown. Within this exception I attempt to clear System.in by resetting it, reading all remaining bytes, marking it, using BufferedInputStream to no avail.
One System.in.read() blocks, there is no return value for EOF (-1).
Any clear ways to reset the System.in and clear the InputStream?