// @topic S-0301-01-10-12 Java console window animation // @brief uses Java Thread.sleep() package console_animation; public class ConsoleAnimation { public static void main( String[] args ) { // animation loop final int DISPLAY_SIZE = 90; for ( int idx = 0; idx < 20; ++idx ) { try { Thread.sleep( 200/*milliseconds*/ ); } catch ( InterruptedException ex ) { } System.out.print("\r"); // carriage return on the same line //system("cls"); // clear screen -- windows-specific char[] animation_frame = new char[ DISPLAY_SIZE ]; for ( int pos = 0; pos < animation_frame.length; ++pos ) { animation_frame[ pos ] = ' '; } animation_frame[ idx ] = '['; animation_frame[ idx + 1 ] = 'A'; animation_frame[ idx + 2 ] = ']'; System.out.print( animation_frame ); } System.out.println(); } }