Answer the question
In order to leave comments, you need to log in
Hex colors in Java console output. Is it possible to?
Hello! I know that there are regular (ANSI) colors that are found in Google in 3 seconds, but I need other colors.
import java.io.*;
public class test {
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 final String ANSI_BLACK_BACKGROUND = "\u001B[40m";
public static final String ANSI_RED_BACKGROUND = "\u001B[41m";
public static final String ANSI_GREEN_BACKGROUND = "\u001B[42m";
public static final String ANSI_YELLOW_BACKGROUND = "\u001B[43m";
public static final String ANSI_BLUE_BACKGROUND = "\u001B[44m";
public static final String ANSI_PURPLE_BACKGROUND = "\u001B[45m";
public static final String ANSI_CYAN_BACKGROUND = "\u001B[46m";
public static final String ANSI_WHITE_BACKGROUND = "\u001B[47m";
public static void main(String args[]) {
System.out.print(ANSI_BLACK_BACKGROUND + ANSI_WHITE + "Белый текст на чёрном фоне." + ANSI_RESET);
}
}
public static final String ANSI_WHITE = "\u001B[37m";
public static final String ANSI_WHITE_BOLD = "\u001B[37;1m";
public static final String ANSI_WHITE_WAT = "\u001B[37;2m";
public static final String ANSI_WHITE_ITALIC = "\u001B[37;3m";
public static final String ANSI_WHITE_UNDERLINED = "\u001B[37;4m";
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question