[Bluej-discuss] "Backspace" escape character

Michael Kölling M.Kolling at kent.ac.uk
Fri Jan 11 16:28:39 GMT 2008


The backspace ('\b') character, when printed, may have different  
results on different terminals and devices.

The behaviour of printing a backspace to a terminal is terminal- 
dependant, and not specified in the Java spec. It is therefore  
dangerous to use and should usually be avoided. In BlueJ, it is not  
interpreted as a backspace, and may appear different, depending on the  
font used. Sometimes as a random symbol (such as your box), sometimes  
not at all.

Michael


On 11 Jan 2008, at 14:53, TJ Evert wrote:

> Dear all,
>
> My class and I are writing methods that act on Strings and (in the  
> past) I've used the "\b" escape character for an "untype()" method  
> (which uses a delay() method) as follows:
>
> public static void untype(String str)
> {
>     int len = str.length();
>     System.out.print(str);
>
>     for(int i = 0; i < len; i++)
>     {
>         delay(1000);
>         System.out.print("\b \b");
>     }
> }
>
> public static void delay(long milliSeconds)
> {
>     long now = System.currentTimeMillis();
>     long later = now + milliSeconds;
>
>     while(later > now)
>     {
>         now = System.currentTimeMillis();
>     }
> }
>
> The problem is that BlueJ types out a "box" character. Any thoughts?
>
> TJ Evert
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss



More information about the bluej-discuss mailing list