public static boolean getUserInputExitKey() {
    System.out.println("Please enter key to continue or the 'q' key to exit.");
    try {
        if ((char)System.in.read() == 'q') return true;
    }
    catch (IOException e) {
        System.out.println("Error user key reading");
    }
    return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////
do {
    // do whatever..
} while(!getUserInputExitKey());
	