Make the console wait for a user input to close

后端 未结 8 989
遥遥无期
遥遥无期 2020-11-30 01:49

I have a console application that after performing its tasks, must give feedback to the user, such as \"operation completed\" or \"operation failed\" and the detailed error.

8条回答
  •  既然无缘
    2020-11-30 01:56

    I used simple hack, asking windows to use cmd commands , and send it to null.

    // Class for Different hacks for better CMD Display
    import java.io.IOException;
    public class CMDWindowEffets
    {
        public static void getch() throws IOException, InterruptedException
        {
            new ProcessBuilder("cmd", "/c", "pause > null").inheritIO().start().waitFor();
        }    
    }
    

提交回复
热议问题