Source Code : Password Prompting with java.io.Console
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Password Prompting with java.io.Console
import java.io.Console;
import java.util.Arrays;
public class PasswordPromptingDemo {
public static void main(String[] args) {
Console console = System.console();
if (console == null) {
System.out.println("Console is not available");
System.exit(1);
}
char[] password = "mustang".toCharArray();
char[] passwordEntered = console.readPassword("Enter password: ");
if (Arrays.equals(password, passwordEntered)) {
System.out.println("
Access granted
");
Arrays.fill(password, );
Arrays.fill(passwordEntered, );
System.out.println("OK ...");
} else {
System.out.println("Access denied");
System.exit(1);
}
}
}
Thank with us