效果:
设置控制台打印字体颜色、背景、字体样式,java工具类
package org.dxl.log;
import java.util.Arrays;
/**
* 在控制台按照传入格式输出
*
* @author IT_CREAT
* @date 2021 2021/1/17/017 4:49
*/
public class ColorPrint {
/**
* 分号
*/
private static final String SEMICOLON = ";";
/**
* 默认黑色打印
*
* @param txt 信息
*/
public static void outPrintln(String txt) {
System.out.println(format(txt, PrintCode.BLACK));
}
/**
* 换行打印
*
* @param txt 信息
* @param codes 格式化参数
*/
public static void outPrintln(String txt, PrintCode... codes) {
System.out.println(format(txt, codes));
}
/**
* 不换行打印
*
* @param txt 打印内容
* @param codes 格式化参数
*/
public static void outPrint(String txt, PrintCode... codes) {
System.out.print(format(txt, codes));
}
/**
* 默认红色打印
*
* @param txt 信息
*/
public static void errorPrintln(String txt) {
System.err.println(format(txt, PrintCode.RED));
}
/**
* 换行打印
*
* @param txt 信息
* @param codes 格式化参数
*/
public static void errorPrintln(String txt, PrintCode... codes) {
System.err.println(format(txt, codes))