Advertisement
Guest User

Untitled

a guest
Jan 10th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. /**
  2. * Filename : ConsolePassword.java
  3. * @package : com.fivedots
  4. *
  5. * ConsolePassword is inside "Hello" project. Thus CD into the folder first, my case its "F:\workspace\Hello\"
  6. * - cd F:\workspace\Hello
  7. * - cd src
  8. * - javac "com/fivedots/ConsolePassword.java"
  9. * - java com.fivedots.ConsolePassword
  10. **/
  11. import java.io.Console;
  12.  
  13. public class ConsolePassword {
  14. public static void main(String[] args) {
  15. Console cons = System.console();
  16.  
  17. String username = cons.readLine("Enter username: ");
  18.  
  19. char[] passwd = cons.readPassword("Enter password: ");
  20.  
  21. System.out.println("Username :"+username);
  22. System.out.println("password :"+passwd);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement