Hi all,

I am reading values (user name and password) from user's input, and I need to mask the password which is entered by user in the command line...

Can someone give me a hint which class do I need to look at?

Appreciate your inputs.


Thanks.

If you are using Java 1.6, the Console class provides a mechanism for this:
http://java.sun.com/docs/books/tutorial/essential/io/cl.html

Thanks for reply,

Unfortunately I don't user Java 1.6, and Console doens't work for me.

I am using the follwoing code, but there's a minor issue with that. Can someone advise, please.

public void run () {
       stop = true;
       while (stop) {
          System.out.print("\010*");
     try {
        Thread.currentThread().sleep(1);
          } catch(InterruptedException ie) {
             ie.printStackTrace();
          }
       }
    }

This is just a snipt of the code, which masks the user's input to asktrisks.

When I run my program from within Eclipse IDE, and before the user gets prompted to enter a password, it goes to an infinit loop. However, when I run my program from a command prompt, like

C:>java Myprogram.java

Then it's ok. Can someone please advise...


Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.