Is there is an alternative to the "\b" character, the backspace character, which deletes the text you just printed? It does not work in the Eclipse console.
Asked
Active
Viewed 1.8k times
3
-
@MarkoTopolnik Just realized that there is a language called **B** :) – Suresh Atta Aug 21 '13 at 10:20
-
@sᴜʀᴇsʜᴀᴛᴛᴀ *B* is what *C* was named after :) – Marko Topolnik Aug 21 '13 at 10:22
-
1Oh, sorry, I'm using java in eclipse, and the "\b" command (the one where it deletes the text you just printed), is buggy. Just looking for an alternative in the command – Ty De Salis Aug 21 '13 at 10:22
-
1So you mean the *backspace character*. It is not a command, it is a control-code defined in ASCII. And you are right, it won't work in the Eclipse console because it doesn't interpret any control codes beside whitespace, and there is no workaround in Eclipse, either. – Marko Topolnik Aug 21 '13 at 10:23
-
Could you elaborate more what is your problem? – Averroes Aug 21 '13 at 10:23
-
Well, I'm making a clock, And I've had to use println. So the only way for it to look like its printing in the same place is minimise the console so only one line shows at a time. – Ty De Salis Aug 21 '13 at 10:25
-
See also http://stackoverflow.com/questions/3095986/how-to-get-backspace-b-to-work-in-eclipses-console – Raedwald Aug 21 '13 at 12:19
2 Answers
2
The Eclipse Console View is not a terminal emulator and doesn't even try to interpret any control codes besides the whitespace. Therefore the behavior isn't "buggy", it is like that by design.
If you want to get control chars like \b
(backspace) interpreted, your best bet is to run the Java program from the command line. Even in Windows' cmd
it should work for \b
.
The \r
(carriage return) character should also work for you on the command line. The advantage is that you need just one to get all the way back to the beginning of the line.

Marko Topolnik
- 195,646
- 29
- 319
- 436
0
I agree with Marko, use different Compiler , or make a method for it instead
public static String b(String text){
return text.substring(0,text.length()-1);
}
System.out.println( b("This is my text") );
:P

misserandety
- 122
- 1
- 4
- 13