Package java.io

Examples of java.io.Console.writer()


            PrintWriter writer = null;
            final String encoding = System.getProperty(OUTPUT_ENCODING_KEY);
            if (encoding == null) {
                final Console console = System.console();
                if (console != null) {
                    writer = console.writer();
                }
            }
            if (writer == null) {
                if (encoding != null) try {
                    writer = new PrintWriter(new OutputStreamWriter(System.out, encoding));
View Full Code Here


    }
  }

  private static ProgressMonitor createProgressMonitor() {
    final Console con = System.console();
    return con == null ? NullProgressMonitor.INSTANCE : new TextProgressMonitor(con.writer());
  }

  private static RuntimeException failCreateBundle(final Throwable cause) {
    throw new FileTreeSnapshotException(cause);
  }
View Full Code Here

            default:
                resultat = Double.NaN;
                break;
        }
       
        c.writer().println("Resultat: " + resultat);
    }
   
    /**
     * Will fetch a {@code Console}, or exit the application
     * if none is attached to the running JVM.
View Full Code Here

        DirectionEnum down = DirectionEnum.valueOf("DOWN");
    }

    private static char getCharFromUser() {
        Console c = System.console();
        c.writer().print("Type in what direction you want to move in (WSAD): ");
        c.writer().flush();

        try {
            return (char) System.console().reader().read();
        } catch (IOException e) {
View Full Code Here

    }

    private static char getCharFromUser() {
        Console c = System.console();
        c.writer().print("Type in what direction you want to move in (WSAD): ");
        c.writer().flush();

        try {
            return (char) System.console().reader().read();
        } catch (IOException e) {
            throw new UncheckedIOException(e);
View Full Code Here

            if (makeTry(c, secret) == true) {      // <-- may be simplified to "if (makeTry(c, secret)) break;".
                break;
            }
        }
       
        c.writer().println("Game over :'(");
       
        // 2. Play again?
        if (playAgain(c) == true) {
            main(null);
        }
View Full Code Here

       
        final int input = getHumanGuess1(c);
        final int comparison = secret.guess(input);
       
        if (comparison > 0) {
            c.writer().println("Too high!");
        }
        else if (comparison < 0) {
            c.writer().println("Too low!");
        }
        else {
View Full Code Here

       
        if (comparison > 0) {
            c.writer().println("Too high!");
        }
        else if (comparison < 0) {
            c.writer().println("Too low!");
        }
        else {
            c.writer().println("Right on spot!");
        }
       
View Full Code Here

        }
        else if (comparison < 0) {
            c.writer().println("Too low!");
        }
        else {
            c.writer().println("Right on spot!");
        }
       
        // Bad, looks ugly:
//        if (comparison == 0) {
//            return true;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.