title: Is it possible to rewrite previous line in console?
body: <p>I'm trying to create process animation in my console app. Is it possible to rewrite previous lines for this needs? I know about <code>\r</code> but it works only with current line. </p>
  
  <p>If it is not possible, how could I achieve animation effect? Thanks.</p>
  
  <p><em>My console is standard Ubuntu 12.04 terminal emulator.</em></p>
  
  <hr>
  
  <p>Thanks to @MrSmith42 I made this simple demo, which shows way to overwrite lines:</p>
  
  <pre><code>public class Flush {
      public static void main(String[] args) {
          for(int i = 0; i &lt; 5; i++) {
              System.out.println("**********************************");
          }
          // ESC[5A - cursor up 5 times
          // \r - cursor return to begin of line
          // ESC[J - erase to end of screen
          System.out.print("\033[5A\r\033[J");
          for(int i = 0; i &lt; 5; i++) {
              System.out.println("##################################");
          }
      }
  }
  </code></pre>