英文:
How can I print a message in bold using system.out on Eclipse console in Java?
问题
如何在Java的Eclipse控制台使用System.out.println()以粗体打印消息?
英文:
How can I print a message in bold using System.out.println() on Eclipse console in Java?
答案1
得分: 0
System.out.print("\033[0;1m" + "你的文本");
英文:
System.out.print("\033[0;1m" + "your text");
答案2
得分: 0
Ideally, you can't as unformatted text is sent to the stdout. However, you can use character sequences that allow for such a thing -
public class TimepassBold {
public static void main(String args[]) {
System.out.print("\u001B[1m This is bold text");
}
}
I tried this in git bash and IntelliJ Idea, it works.
If you'd really like to colorize your logs, have a look at this.
Edit - Thanks Greg for correcting me. This won't work in Eclipse, it is simply just a terminal, nothing else.
英文:
Ideally, you can't as unformatted text is sent to the stdout. However, you can character-sequences that allow for such a thing -
public class TimepassBold {
public static void main(String args[]) {
System.out.print("\u001B[1m This is bold text");
}
}
I tried this in git bash and IntelliJ Idea, it works.
If you'd really like to colorize your logs, have a look at this.
Edit - Thanks Greg for correcting me. This won't work in Eclipse, it is simply just a terminal, nothing else.
答案3
得分: -1
使用 log4j
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
英文:
use log4j
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
专注分享java语言的经验与见解,让所有开发者获益!
评论