• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing backspace...

 
Gurumurthy Ramamurthy
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9313
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The backspace "character" is a terminal control character which moves the cursor one space backwards. Try this:
 
Gurumurthy Ramamurthy
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no luck...
It prints

Guru
X

no sign of moving one space backwards
 
Joe Ess
Bartender
Posts: 9313
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice that I use System.out.print(), not println.
 
Gurumurthy Ramamurthy
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool man..it worked...thanks a lot.
Guru
 
Ron Hollander
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic