Backspace char ('\b') does not work in run/debug output
Anyone run into a problem with System.out and the backspace character ('\b')? It seems to not work when running/debugging in the IDE - it outputs garbage characters. Works fine when the code is run from a Windows/Unix console...
Here is an example:
import java.io.*;
import java.util.*;
public class testBackspace
{
private static int progressMeterState = 0;
public static void main(String[] params) throws InterruptedException, IOException
{
String out = "";
for (int i = 1; i <= 100; i++)
{
//Backspace first...
char[] chars = new char[out.length()];
Arrays.fill(chars, '\b');
System.out.print(chars);
out = "Write to console #" + i;
System.out.print(out);
Thread.sleep(100);
}
System.out.print("\n");
}
}
Please sign in to leave a comment.