java System.out.println 输出带颜色的字符串到 stdout
Posted PeersLee
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java System.out.println 输出带颜色的字符串到 stdout相关的知识,希望对你有一定的参考价值。
Unix shell ANSI escape code
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";
举个例子
以上是关于java System.out.println 输出带颜色的字符串到 stdout的主要内容,如果未能解决你的问题,请参考以下文章
java中System.out.print()与System.out.println()与System.out.printf()的差别
JAVA中System.out.println和System.out.print有啥区别?
JAVA中System.out.println和System.out.print有什么区别
java中的system.out.println()和JSP中out.println()差别