I need to write a console application in which via System.out.println("Какой-то текст"); text is displayed.

Is it possible to somehow set the text color in the code?

    1 answer 1

    Yes, it is possible (but it will not work everywhere):

     public class Main { public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED = "\u001B[31m"; public static final String ANSI_GREEN = "\u001B[32m"; public static final String ANSI_YELLOW = "\u001B[33m"; public static final String ANSI_BLUE = "\u001B[34m"; public static final String ANSI_PURPLE = "\u001B[35m"; public static final String ANSI_CYAN = "\u001B[36m"; public static final String ANSI_WHITE = "\u001B[37m"; public static void main(String[] args) { System.out.println(ANSI_RED + "This text is red!" + ANSI_RESET); } }