Java Console readLine : Console « JDK 6 « Java

Java Console readLine


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 username = console.readLine("Enter username: ");


Related examples in the same category

1.Password Prompting with
2.Console read Password
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?