0

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;
 }

}

Edited by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by madonline
0

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()?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.