Я хотел распечатать цветный текст в консоли Java. Я запустил следующий код в VSCODE, и он работает нормально, и он не работает в CMD.
// Java Program to Print Colored Text in Console
// Importing input output classes
import java.io.*;
// Main class
public class GFG {
// Declaring ANSI_RESET so that we can reset the color
public static final String ANSI_RESET = "\u001B[0m";
// Declaring the color
// Custom declaration
public static final String ANSI_YELLOW = "\u001B[33m";
// Main driver method
public static void main(String[] args)
{
// Printing the text on console prior adding
// the desired color
System.out.println(ANSI_YELLOW + "This text is yellow" + ANSI_RESET);
}
}
`
Источник: https://www.geeksforgeeks.org/how-to-pr ... a-console/
Запуск кода в терминале Windows Cmd Показывает:
D:\CodeSpaceOfline\sudocu>java sudoco.java
←[31mThis text is yellow←[0m`
Подробнее здесь: https://stackoverflow.com/questions/743 ... not-in-cmd