CAN SOMEONE TELL ME HOW THE console eraser work in the below PROGRAM PART...............describe the LOGIC???????????

//Creating and hiding password. 		
		  
	ConsoleEraser consoleEraser    = new ConsoleEraser();
			System.out.println();
			System.out.println("(Please enter the common Password)");
			System.out.print("PASSWORD : ");

  		  BufferedReader passin = new BufferedReader(new
        InputStreamReader(System.in));

		consoleEraser.start();                       
  				String passWord = passin.readLine();
  		consoleEraser.halt();
  			System.out.print("\b");
//Password matching.
	
	if("libStaff".equals(passWord))	{
	  		
//password testing by printing	System.out.println("Password: '" +    passWord     +  "'" );
  	   			a1.Interface	();
	   			m1.mainMenu 	();
		}	   
  	
	else	{
			System.out.println();
			System.out.println("You have entered a invalid password!!!");
	  		System.out.println("Please enter a correct password...");	
				p1.Pass		();

		}


	}

} 

class ConsoleEraser extends Thread {
 
        private boolean running = true;
	public void run(){
 	 		 while (running) {
   	 		   System.out.print("\b ");
                              }
               		 } 


 public synchronized void halt() {
  running = false;
 }

}

Recommended Answers

All 2 Replies

Escape char \b (backspace) and space.
try this,

public class Sample
{
  public static void main(String []args)
  {
       System.out.println("Help\b ");
   }
}

Do you know System.console().readPassword()?

thanks for your reply....

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.