clrscr and getch in java - Programmers Heaven

Howdy, Stranger!

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

Categories

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.