zl程序教程

您现在的位置是:首页 >  其他

当前栏目

打印控制台->字体与颜色

2023-04-18 15:37:36 时间

方法如何??

    /**
     * @param content 文本内容
     * @param colour  颜色代号:31->红色、32->黄色、33->橙色、34->蓝色、35->紫色、36->绿色
     * @param type    样式代号:0无;1加粗;3斜体;4下划线
     * @return
     */
    private static String getFormatLogString(String content, int colour, int type) {
        boolean hasType = type != 1 && type != 3 && type != 4;
        if (hasType) {
            return String.format("33[%dm%s33[0m", colour, content);
        } else {
            return String.format("33[%d;%dm%s33[0m", colour, type, content);
        }
    }

如果使用??

    /**
     * 打印log.info也不印象
     */
System.out.println(getFormatLogString("唐僧",32,0))