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

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

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

&lt;dependency&gt;
    &lt;groupId&gt;log4j&lt;/groupId&gt;
    &lt;artifactId&gt;log4j&lt;/artifactId&gt;
    &lt;version&gt;1.2.17&lt;/version&gt;
&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:

确定