Example usage for java.io Console flush

List of usage examples for java.io Console flush

Introduction

In this page you can find the example usage for java.io Console flush.

Prototype

public void flush() 

Source Link

Document

Flushes the console and forces any buffered output to be written immediately .

Usage

From source file:Main.java

public static void main(String[] args) {

    Console ob = System.console();

    ob.printf("from java2s.com");

    ob.flush();
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    Console cnsl = System.console();

    // test for console not null
    if (cnsl != null) {

        // read line from the console
        String name = cnsl.readLine("Enter  name  : ");

        // print//from  www  .j  a  v a2  s.c o m
        System.out.println("You have entered : " + name);
    }

    // flushes console and forces output to be written
    cnsl.flush();

}

From source file:org.olamy.puzzle.robot.input.cli.RobotMoverInputBuilderCli.java

private RobotOrder getRobotOrder(Console console, PrintWriter writer, Table table)
        throws UnknownOrientationException, OutOfTableException {
    writer.write("Robot start position and orientation (sample PLACE 1,2,EAST ) : ");
    console.flush();
    String robotStart = console.readLine();
    RobotOrder robotOrder = RobotOrderUtils.buildRobotOrderStart(robotStart, table);

    writer.write("Robot orders (sample RIGHT, LEFT, MOVE, REPORT ) (end input with empty line) : "
            + SystemUtils.LINE_SEPARATOR);
    console.flush();//from   w  w w. j  a v  a 2s. c  o  m
    return robotOrder.setOrders(readOrders(console, writer));
}