How to get backspace \b to work in Eclipse's console?
Eclipse Bug #76936. I wouldn't count on them to fix it, and there are no workarounds listed.
You might have luck finding a plugin that contributes a more advanced console.
How to Achieve -r,-b,-f in eclipse
The Eclipse console does not support any of \b, \f, or \r properly. \r is treated as a new line, the others as spaces.
This is described in Eclipse bug 76936 which has been open since 2004 and despite some attempts to fix is still open.
Java backspace escape
Java doesn't 'handle' that character at all. All it knows about is a byte stream onto which the OS says it can write bytes, and it will happily write bytes into it, including an ASCII backspace.
What happens when the stream receives that character has nothing whatsoever to do with Java, it is totally terminal-dependent. Some terminals will erase the previous character, some will display the backspace character as some weird glyph, or even as a special "backspace character" glyph. Some may drop the character altogether if they can't interpret it, others (most terminal emulators, in fact) will behave differently depending on how they're configured. But all this has nothing to do with Java, they will behave that way whether they're written to by Java or Perl print
or C++ cout
or whatever else.
\b in Java - Windows implemented
I don't know about Eclipse's failures (god knows I've pulled enough hair out trying to fix issues my coworker gets using Eclipse), but could you manage with using the [home] character?
System.out.print("Hello!" + (char)13);
System.out.print(" ");
System.out.print("Hello");
It's a kludge compared to \b
for your purpose, but if the output you're using doesn't work with one control character, try another! :)
Backspace \b Chacacter Scope with regard to OS?
Can I write the backspace char to file to delete previously written test?
No.
Can I delete a newline ("\r\n" or either) character with \b.
No.
The only situations where characters like \b
will be interpreted like this are when you are writing to a screen, console or terminal.
Characters written to a file are not treated like this.
This is not a Java-specific restriction. Rather it is inherent in the way that operating systems1 handle writing data to files.
1 - That is ... every OS that I have encountered.
C++: Cannot delete characters already printed to console before outputting
The problem has something to do with MacOS. I tried backspacing fixed input and nothing was deleted even when I just output '\b'
. I ran my program in Visual Studio and it outputs as expected, so I have concluded that either Eclipse on MacOS or MacOS itself does not support '\b'
.
Related Topics
Running Java in Package from Command Line
How to Identify End of Inputstream in Java
How to Read Properties File in Web Application
Cannot Change Version of Project Facet Dynamic Web Module to 3.0
How to Monitor Java Memory Usage
Should Getters and Setters Be Synchronized
Is There Any Performance Reason to Declare Method Parameters Final in Java
Java.Lang.Noclassdeffounderror: Org/Hamcrest/Selfdescribing
How to Parse Case-Insensitive Strings with Jsr310 Datetimeformatter
Appearance of Java Security Dialog
Call a Method of Subclass in Java
Is There a MACro Recorder for Eclipse
Checked VS Unchecked Exception
Registering and Using a Custom Java.Net.Url Protocol
Tomcat 8 Is Not Able to Handle Get Request with '|' in Query Parameters
How to Enumerate Ip Addresses of All Enabled Nic Cards from Java
In Java, How to Efficiently and Elegantly Stream a Tree Node's Descendants