Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"\b" in Java - Windows implemented

Tags:

java

backspace

Working on Java in a Windows-run computer lab.

System.out.print ("Hello!");
System.out.print ("\b");

Prints

Hello![]

Where [] is a box, so as to signify a character the font doesn't support, or has an invalid ASCII value or something.

This is something pretty primitive, and comes in handy to make fancy looking terminal applications, so please help me out :)

like image 773
Angad Avatar asked Dec 28 '22 11:12

Angad


2 Answers

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! :)

like image 84
Brian S Avatar answered Jan 10 '23 14:01

Brian S


This problem indeed occurs in at least Eclipse's console, but certainly not in Windows command console.

Also see this related topic: How to get backspace \b to work in Eclipse’s console?

like image 21
BalusC Avatar answered Jan 10 '23 16:01

BalusC