Search Results

Search found 1 results on 1 pages for 'denchr'.

Page 1/1 | 1 

  • What is an appropriate way to programmatically exit an application?

    - by denchr
    I am evaluating user inputs as commands for my application. If the user presses Q, or q, and then hits enter, the application quits and execution terminates. Is there a proper context, or best practices on how to do that? I do not have any resources to release, or anything like that. Should I just use System.exit(0);? Is there a recommended way to do that? As my first approach I do something like this: while (true){ try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //Other logic goes here... if (br.readLine().equalsIgnoreCase("Q")){ System.exit(0); } } catch (IOException ioe) { System.out.println("IO error trying to read your selection"); } }

    Read the article

1