title: Filter character of console input in Java
body: <p>I'm writing a terminal version of my Java application, and this is the first time I do this. I tried <code>Scanner</code> and <code>Console</code>, but as far as I investigated, these classes only allow me to receive user input after he/she finish inputting (no manipulating/filtering).</p>
  
  <p>For example, I want the user inputs his age, but if he inputs a meaningless string, all I can do is validating the string and requesting him to input again. What I really want is only allow him to input integer, i.e when he press any key which is not a number, the character will not be displayed on console. Using Swing and <code>JTextField</code> I can do this easily with <code>DocumentFilter</code>, but with console only, I still haven't found a way.</p>
  
  <p>Any help is appreciated. Thanks all.</p>