Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

clrscr and getch in java

zhi_yizhi_yi Posts: 28Member
hi there.

please help me, how to clear screen and getch in java?

thanks

Comments

  • r035198xr035198x Posts: 5Member
    : hi there.
    :
    : please help me, how to clear screen and getch in java?
    :
    : thanks
    :
    For clearing the screen you have to do something so complicated that i suggest you have nothing to do with it.

    For getch however, java treats the console like a stream lets say like a file.It reads it and writes to it as it would a file. Here is how to do it
    [code]
    import java.io.*;
    class Console {
    public static void main(String[] arguments ) {

    BufferedReader inputStream = null;
    try {
    inputStream = new BufferedReader(new InputStreamReader(System.in));
    String line = inputStream.readLine();
    System.out.println("The text you entered is " + line ) ;
    }
    catch(IOException s) {
    s.printStackTrace();
    }
    }
    }

    [/code]
    Now you may or may not know some of constructs in there. You can use them without fully understanding them until you get to understand java's IO and exception handling
Sign In or Register to comment.