Ok, this is crazy. This is the simplest program:
import java.io.*;
public class HerbertTest
{
static final char ECHO_CHAR = '-';
public static void main(String args[]) throws Exception
{
BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
String line = null;
printPrompt();
while ((line = in.readLine()) != null)
{
// Trim whitespace
line = line.trim();
// Get hidden representation
String hidden = getHidden(line);
// Print it out
System.out.println("Your hidden word is: " + hidden);
printPrompt();
}
}
public static String getHidden(String str)
{
if (str == null || str.length() == 0)
return "";
int len = str.length();
StringBuffer buf = new StringBuffer();
for (int i = 0; i < len; i++)
buf.append(ECHO_CHAR);
return buf.toString();
}
public static void printPrompt()
{
System.out.print("Enter a word to echo and press <Enter>:"

;
System.out.flush();
}
}
I've compiled this and run it and it does exactly what you want to the console.