Saturday, 20 December 2014

Clear command line console and display bold size of string in Java Command Line Application


To clean console of your command line application,use following code :


  /**  
   * This method clear the current screen  
   *   
   *   
   */  
   public static void clearScreen() {  
    System.out.print("\033[H\033[2J");  
    System.out.flush();  
   }  



To make bold size of any string,

  public void boldSizeOfString()  
   {  
       String strNormalSize = "\033[0;0m";  
       String strBoldSize = "\033[0;1m";  
         System.out.println (strNormalSize + "My Name is Anthony Gonsalves" + strBoldSize);  
   }  














11 comments:

  1. Replies
    1. Try running your Program in Command Line and check if it works or not.

      Delete
  2. Hi can you explain or link to why it's working.. What is it actually doing?
    best Regards Jonas

    ReplyDelete
  3. I'm using eclipse, it's not working

    ReplyDelete
    Replies
    1. Eclipse and other IDEs use TextPanels try to run your program in console/terminal it works perfectly fine :)

      Delete
  4. Does that work in windows?

    ReplyDelete
    Replies
    1. Yes after you have compiled your program and execute it from the Windows-Shell it will work

      Delete
  5. how i clear my console in eclipise ide??

    ReplyDelete