2

I was trying to display a String and then clear it after some time.
The following code is working.

    String hello = "Hello";
    System.out.print(hello);
    int length = hello.length();
    for (int i = 0; i < length; i++)
        System.out.print("\b");


But when I thought to display it for few seconds (Using Thread.sleep(time) ), it is not working (code below). When I was debugging it I noticed that after the first execution of the loop, cursor starts pointing to the next line.
So, Is there any way to display for few seconds and then clear it.

String hello = "Hello";
System.out.print(hello);
int length = hello.length();
Thread.sleep(10);
for (int i = 0; i < length; i++)
    System.out.print("\b");
Meo
  • 12,020
  • 7
  • 45
  • 52

1 Answers1

1

IDEA-86669 Console: support ASCII backspace symbol in console view

Mark Jeronimus
  • 9,278
  • 3
  • 37
  • 50
Meo
  • 12,020
  • 7
  • 45
  • 52
  • I do not know who down voted your comment and my question. But I found that this issue is already opened in the link you provided and its unresolved –  Feb 17 '18 at 07:12
  • I can not upvote it, because my reputation fell down from 16 to 11 because of downvote :/ , sorry –  Feb 17 '18 at 07:25
  • 1
    Regarding the answer, it is not an actual answer. Because answer is really donot use Intellij or eclipse (because it worked in netbeans and command line) –  Feb 17 '18 at 07:26
  • You asked about IntelliJ, this is the best answer you will get. Maybe it will be implemented in the future. – Meo Feb 17 '18 at 07:51
  • 2
    you are right (I also updated the tag to intellij). And, In that context, I am accepting this answer –  Feb 17 '18 at 08:08