工具类(有颜色的控制台输出)

public class ColorUtils {
    private static final int DEFAULT = 39;
    private static final int BLACK = 30;
    private static final int RED = 31;
    private static final int GREEN = 32;
    private static final int YELLOW = 33;
    private static final int BLUE = 34;
    private static final int MAGENTA = 35;
    private static final int CYAN = 36;
    private static final int WHITE = 37;

    private static String colorStr(String msg, int colorCode) {
        return "\u001b[" + colorCode + "m" + msg + "\u001b[0m";
    }

    public static void main(String[] args) {
        System.out.println(colorStr("你好",RED));
    }
}

你可能感兴趣的:(工具类,java,开发语言)