Very simple Java library that modifies Strings in the way they are colored when printed to terminal. It uses ANSI codes to do the job.
Tested with OSes:
- Linux - different distributions
- MacOS
- Windows 10 and 11 (in Windows 10 coloring is off)
The compiled libraries are deployed to Maven Central.
Usage with maven:
<dependency>
<groupId>io.github.kamilszewc</groupId>
<artifactId>java-ansi-text-colorizer</artifactId>
<version>1.4</version>
</dependency>
Usage with gradle:
implementation 'io.github.kamilszewc:java-ansi-text-colorizer:1.4'
Currently, there are two static methods that can be used to color text or background printed to terminal
-
Text example:
System.out.println(Colorizer.color("Some text", Colorizer.Color.RED));
will print the text in red color.
-
Backgound example:
System.out.println(Colorizer.color("Some text", Colorizer.BackgroundColor.RED));
will print the background in red color.
Apache License 2.0 Copyright 2022 Kamil Szewc