Console read Password : Console « JDK 6 « Java

Console read Password


import java.sql.SQLException;

public class MainClass {
  public static void main(String[] args) throws ClassNotFoundException, SQLException {
    Console console = System.console();
    if (console == null) {
      System.err.println("sales: unable to obtain console");

    String password = new String (console.readPassword ("Enter password: "));


Related examples in the same category

1.Java Console readLine
2.Password Prompting with
3.Console output with format
4.Printing text with the Console class
5.Masking a password with the Console class
6.Use Console class to read user input?