Edit: code has been solved. This solution has only been tested to work for cmd. That is, it may not work for Eclipse.
The corrected code is now:
String code = "Generating code...\r";
String successful = code.replaceAll("Generating code...\r", "Generating the code has been successful.\r");
Original Issue: I want to be able to display a String for two seconds, then after waiting two seconds, I then want that String to be replaced by another String.
I have attempted a basic structure, but it does not appear to replace the code, and instead appears below it.
Code:
String code = "Generating code...\n\n";
String successful = code.replaceAll("Generating code...\n\n", "Generating the code has been successful.\n\n");
[...]
try {
System.out.print(code);
Thread.sleep(2000);
System.out.print(successful);
}
catch(InterruptedException e) {
[...]
}
What this code does currently is print Generating Code... then after two seconds it will print Generating the Code has been successful... on two new lines.
However, instead of it printing two new lines down, I want the String Generating the Code has been successful to overwrite the String Generating Code... only after the two second have elapsed.