투케이2K

206. (java/자바) System out println 콘솔 (console) 로그 색상 변경 실시 본문

Java

206. (java/자바) System out println 콘솔 (console) 로그 색상 변경 실시

투케이2K 2021. 7. 9. 07:50

/* =========================== */

[ 개발 환경 설정 ]

개발 툴 : Eclipse

개발 언어 : Java

/* =========================== */

/* =========================== */

[소스 코드]

 

package ex5;

public class MainActivity16 {
	
	// [전역 변수 선언 부분]
	public static final String RESET = "\u001B[0m";    
	public static final String FONT_BLACK = "\u001B[30m";    
	public static final String FONT_RED = "\u001B[31m";     
	public static final String FONT_GREEN = "\u001B[32m";    
	public static final String FONT_YELLOW = "\u001B[33m";     
	public static final String FONT_BLUE = "\u001B[34m";   
	public static final String FONT_PURPLE = "\u001B[35m";     
	public static final String FONT_CYAN = "\u001B[36m";    
	public static final String FONT_WHITE = "\u001B[37m";     
	public static final String BACKGROUND_BLACK = "\u001B[40m";     
	public static final String BACKGROUND_RED = "\u001B[41m";     
	public static final String BACKGROUND_GREEN = "\u001B[42m";    
	public static final String BACKGROUND_YELLOW = "\u001B[43m";     
	public static final String BACKGROUND_BLUE = "\u001B[44m";    
	public static final String BACKGROUND_PURPLE = "\u001B[45m";     
	public static final String BACKGROUND_CYAN = "\u001B[46m";     
	public static final String BACKGROUND_WHITE = "\u001B[47m";
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		// [System.out.println 출력 실시]
		System.out.println(FONT_BLACK + "안녕하세요 !!!" + RESET);
		System.out.println(FONT_RED + "안녕하세요 !!!" + RESET);
		System.out.println(FONT_YELLOW + "안녕하세요 !!!" + RESET);
		System.out.println(FONT_CYAN + "안녕하세요 !!!" + RESET);
		System.out.println(FONT_WHITE + "안녕하세요 !!!" + RESET);
		System.out.println("");
		
		System.out.println(BACKGROUND_BLACK + FONT_WHITE + "안녕하세요 !!!" + RESET);
		System.out.println(BACKGROUND_WHITE + FONT_BLUE + "안녕하세요 !!!" + RESET);
		System.out.println(BACKGROUND_YELLOW + FONT_RED + "안녕하세요 !!!" + RESET);
		System.out.println("");				

	} // [메인 종료]

}// [클래스 종료]

/* =========================== */

/* =========================== */

[결과 출력]

/* =========================== */

 

반응형
Comments