All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.dev.console.TerminalUtils Maven / Gradle / Ivy

There is a newer version: 3.17.0
Show newest version
package io.quarkus.dev.console;

import java.io.Console;
import java.util.logging.Level;
import java.util.logging.Logger;

public class TerminalUtils {

    private static final Logger LOGGER = Logger.getLogger(TerminalUtils.class.getName());

    public static boolean isTerminal(Console console) {
        if (console == null) {
            return false;
        }

        if (Runtime.version().feature() < 22) { // isTerminal was introduced in Java 22
            return true;
        }

        try {
            return (boolean) Console.class.getMethod("isTerminal").invoke(console);
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, "Failed to invoke System.console().isTerminal() via Reflection API", e);
            return false;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy