title: multi-line ascii animation in intellij
body: <p>I'm trying to create a multi line ascii art animation using Intellij, and for that I'm creating an array of strings and I refer to each element of the array as a frame.<br />
  After that, in order for that to work, I need to change what was printed to the console each time unit x.</p>
  <p>I do know that I can replace the last line printed to the console with &quot;\r&quot; like so:</p>
  <pre class="lang-java prettyprint-override"><code>for (int i = 0; i &lt;= 100; i++)
      {
          Thread.sleep(200);
          System.out.printf(&quot;\r %s  &quot;, i);
      }
  </code></pre>
  <p>however it <strong>doesn't delete the older lines printed</strong> (<code>System.out.printf(&quot;\r %s &quot;, &quot;a \n b&quot;);</code> will only replace <code>b</code> in each iteration) and because intellij's console isn't a real console <strong>there is no way to clear the console from code</strong>.</p>
  <p>So is there any other solution or a workaround for that problem that can work for intellij?</p>
  <p>to make things more simple I'll add an example. Let's say I want to print this weight lifting animation (ascii art taken from - <a href="https://ascii.co.uk/art/stickman" rel="nofollow noreferrer">https://ascii.co.uk/art/stickman</a>)</p>
  <pre><code>                                                                 O--,---,--O
                                            ._O_.     O--=-O-=--O     \ O /
      _._                      ,_O_,     O--&lt;-+-&gt;--O      '-'          - -
     / O \        ,-O-,     O--(---)--O       X            v            -
     \| |/     O--=---=--O      &gt;'&gt;          / \          / )          / \
  O--+=-=+--O      2&quot;2          - -         -   -        ~  z         =   =
  </code></pre>
  <p>So I'm creating a 2d array of strings for the frames<br />
  (after that ill create the frame with <code>String.join(&quot;\n&quot;, &lt; frame elements &gt;)</code>).</p>
  <pre class="lang-java prettyprint-override"><code>String[][] frames = 
  {
    {
       &quot;           &quot;,
       &quot;           &quot;,
       &quot;    _._    &quot;,
       &quot;   / O \\   &quot;,
       &quot;   \\| |/   &quot;,
       &quot;O--+=-=+--O&quot;
   },
   {
       &quot;              &quot;,
       &quot;              &quot;,
       &quot;     ,-O-,    &quot;,
       &quot;  O--=---=--O &quot;,
       &quot;      2&quot;2     &quot;
   },
   {
       &quot;              &quot;,
       &quot;     ,_O_,    &quot;,
       &quot;  O--(---)--O &quot;,
       &quot;      &gt;'&gt;      &quot;,
       &quot;      - -      &quot;
   },
   {
       &quot;     ._O_.    &quot;,
       &quot;  O--&lt;-+-&gt;--O &quot;,
       &quot;       X      &quot;,
       &quot;      / \\     &quot;,
       &quot;     -   -    &quot;
   },
   {
       &quot;  O--=-O-=--O &quot;,
       &quot;      '-'     &quot;,
       &quot;       v      &quot;,
       &quot;      / )     &quot;,
       &quot;     ~   Z    &quot;
   },
   {
       &quot;  O--,---,--O &quot;,
       &quot;     \\ O /    &quot;,
       &quot;      - -     &quot;,
       &quot;       -      &quot;,
       &quot;      / \\     &quot;,
       &quot;     =   =    &quot;
   }
  }
  
  </code></pre>
  <p>and in each time unit x+1 I want the console to show frames[x+1] instead of frames[x].</p>
  <p>any ideas?</p>