0

I want the program to wipe out the previous console output. For example i have a data entry program that when the program repeats, the whole output that were inputted must be wiped away in the console for privacy (for instance, if someone you don't know is using the program again and you don't want them to see what you've inputted in the console before). By the way I am using Java in eclipse and I wonder if this thing would be possible.

    String aWord;
    String repeat;
    do {

    Scanner scan = new Scanner(System.in);




    System.out.println("Type anything.");
    aWord = scan.nextLine();

    System.out.println("Do you want to type anything again? Y/N");
    repeat = scan.nextLine();

    while(!repeat.equalsIgnoreCase("y") && !repeat.equalsIgnoreCase("n")) {
            System.out.println("[ERROR] Please answer correctly.");
            repeat = scan.nextLine();
            if (repeat.equalsIgnoreCase("n")) {
                System.out.println("Thanks for using this program!");
                System.exit(0);
            }
        }

    if (repeat.equalsIgnoreCase("n")) {
        System.out.println("Thanks for using this program!");
        System.exit(0);
    }


    }while (repeat.equalsIgnoreCase("y"));
        // if the user answers yes, the program must repeat the whole process.
        // if the user answers yes, the program must wipe out all previous output in the console.
  • https://stackoverflow.com/questions/2979383/java-clear-the-console is it similar to what u want to do here – Ahmed Marzook May 26 '20 at 10:49
  • @AhmedMarzook thanks Ahmed, problem resolved. Now I realized that clearing an output on an IDE's console is impossible, unless you have to import your file into cmd, which I did by the way and it worked perfectly as it should work. – Static_void May 26 '20 at 17:04

0 Answers0