/*
 * Copyright 2014 - 2015 Real Logic Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.co.real_logic.aeron.common.concurrent.console;

import java.io.Console;

/**
 * Barrier to block the calling thread until a command is given on the {@link java.io.Console}
 */
public class ContinueBarrier
{
    final String label;

    /**
     * Create a barrier that will display the provided label and interact via the {@link java.io.Console}.
     *
     * @param label to prompt the user.
     */
    public ContinueBarrier(final String label)
    {
        this.label = label;
    }

    /**
     * Await for input that matches the provided command.
     * @return true if y otherwise false
     */
    public boolean await()
    {
        final Console console = System.console();
        if (null == console)
        {
            throw new IllegalStateException("Console is not available");
        }

        while (true)
        {
            console.printf("\n%s (y/n): ", label).flush();

            final String line = console.readLine();

            return "y".equalsIgnoreCase(line);
        }
    }
}

@@ -666,26 +666,28 @@
 rt java.
-io.Console
+util.Scanner
 ;%0A%0A/**%0A 
@@ -760,36 +760,27 @@
 the 
-%7B@link java.io.Console%7D
+command line.
 %0A */%0A
+%0A
 publ
@@ -916,16 +916,61 @@
 ract
- via the
+%0A     * via %7B@link System#out%7D, %7B@link System#in%7D and
  %7B@l
@@ -982,18 +982,20 @@
 ava.
-io.Console
+util.Scanner
 %7D.%0A 
@@ -1202,16 +1202,23 @@
 ommand.%0A
+     *%0A
      * @
@@ -1303,268 +1303,110 @@
     
-final Console console = System.console();%0A        if (null == console)%0A        %7B%0A            throw new IllegalStateException(%22Console is not available%22);%0A        %7D%0A%0A        while (true)%0A        %7B%0A            console.printf(%22%5Cn%25s (y/n): %22, label).flush();%0A%0A    
+System.out.format(%22%5Cn%25s (y/n): %22, label).flush();%0A        final Scanner in  = new Scanner(System.in);%0A
     
@@ -1433,20 +1433,15 @@
 e = 
-console.read
+in.next
 Line
@@ -1445,20 +1445,16 @@
 ine();%0A%0A
-    
         
@@ -1492,18 +1492,8 @@
 e);%0A
-        %7D%0A
     

Update ContinueBarrier so it can work in an IDE - Issue #72.