aspose file tools*
The moose likes Beginning Java and the fly likes Printing backspace... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Printing backspace..." Watch "Printing backspace..." New topic
Author

Printing backspace...

Gurumurthy Ramamurthy
Ranch Hand

Joined: Feb 13, 2003
Posts: 272
Hello all,

My intention is to print something on the screen, then erase one character back (using '\b'). The following is the program.

class Unicode
{
public static void main(String args[])
{
String name="Guru";
char bc='\b';
System.out.println(name+bc);

}

}

It printed "Guru", I exptected "Gur", since I have given backspace, so it should have deleted the last character "u", it didn't.

Can anyone clarify?

Thanks,
Guru
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9

The backspace "character" is a terminal control character which moves the cursor one space backwards. Try this:


[How To Ask Questions On JavaRanch]
Gurumurthy Ramamurthy
Ranch Hand

Joined: Feb 13, 2003
Posts: 272
no luck...
It prints

Guru
X

no sign of moving one space backwards
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9

Notice that I use System.out.print(), not println.
Gurumurthy Ramamurthy
Ranch Hand

Joined: Feb 13, 2003
Posts: 272
Cool man..it worked...thanks a lot.
Guru
Ron Hollander
Greenhorn

Joined: Feb 27, 2013
Posts: 1
Hi,
I have the same problem, but when I write this code, I get this weird looking black rectangle with a white round inside it...could it be that my java is not up to date and/or that it is because I use Vista?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing backspace...