如何在Eclipse控制台中使用system.out在Java中打印粗体消息?

huangapple 未分类评论57阅读模式
英文:

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 -

  1. public class TimepassBold {
  2. public static void main(String args[]) {
  3. System.out.print("\u001B[1m This is bold text");
  4. }
  5. }

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 -

  1. public class TimepassBold {
  2. public static void main(String args[]) {
  3. System.out.print("\u001B[1m This is bold text");
  4. }
  5. }

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

  1. 使用 log4j
  2. <dependency>
  3. <groupId>log4j</groupId>
  4. <artifactId>log4j</artifactId>
  5. <version>1.2.17</version>
  6. </dependency>
英文:

use log4j

  1. &lt;dependency&gt;
  2. &lt;groupId&gt;log4j&lt;/groupId&gt;
  3. &lt;artifactId&gt;log4j&lt;/artifactId&gt;
  4. &lt;version&gt;1.2.17&lt;/version&gt;
  5. &lt;/dependency&gt;

huangapple
  • 本文由 发表于 2020年4月8日 10:08:19
  • 转载请务必保留本文链接:https://java.coder-hub.com/61092266.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定