Skip to content

Instantly share code, notes, and snippets.

@alan-mushi
Created October 28, 2012 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alan-mushi/3969170 to your computer and use it in GitHub Desktop.
Save alan-mushi/3969170 to your computer and use it in GitHub Desktop.
Barre de progression pour la console en java
public class progressbar {
public static void main( String[] args ) {
System.out.println( "[*] Running ..." ) ;
for ( int i = 1 ; i < 101 ; i++ ) {
System.out.flush() ;
System.out.print( "\r " + ( i == 100 ? "100" : " " + ( i < 10 ? " " + i : i) ) + " % " ) ;
System.out.print( "[" ) ;
for ( int j = 0 ; j < i-1 ; j++ ) { System.out.print( "=" ) ; }
System.out.print( ">" ) ;
for ( int j = i ; j < 100 ; j++ ) { System.out.print( " " ) ; }
System.out.print( "]" ) ;
try { Thread.sleep( 100 ) ; } catch ( InterruptedException e ) {}
}
System.out.println( "\n[+] Complete :)" ) ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment