Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java code to clear screen?

  • 30-05-2007 9:42pm
    #1
    Closed Accounts Posts: 5,240 ✭✭✭


    Anyone know any simple code that can clear the screen at a certain stage, all i could think to do was setup a loop with a load of System.out.println(""); statements which would loop until the screen was clear?

    Cheers
    Endo


Comments

  • Registered Users, Registered Users 2 Posts: 44,200 ✭✭✭✭Basq


    Depends on the OS... on Windows 9x and Unix, you can use:

    System.out.println(((char) 27)+"[2J"); // ANSI clear screen...

    But NOTHING works in Windows NT. So you can use your method above for NT as that's the best bet.

    Hope this helps!


  • Closed Accounts Posts: 5,240 ✭✭✭Endurance Man


    basquille wrote:
    Depends on the OS... on Windows 9x and Unix, you can use:

    System.out.println(((char) 27)+"[2J"); // ANSI clear screen...

    But NOTHING works in Windows NT. So you can use your method above for NT as that's the best bet.

    Hope this helps!

    Ye figured that much, asked my programming lecturer and she didnt even have an answer, will have to stick with the ol loop.


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    how about this
    String clearScreenCommand = null;
    if( System.getProperty( "os.name" ).startsWith( "Window" ) )
       clearScreenCommand = "cls";
    else
       clearScreenCommand = "clear";
    
    Runtime.getRuntime().exec( clearScreenCommand );
    

    checks if it's running windows and all :p


Advertisement