java加粗,java,以粗体显示

这篇博客探讨了如何在Java的System.out.println中使用printf实现文本格式化,尤其是如何打印粗体。它指出Java标准库并不支持直接的粗体输出,但提到了通过解析ANSI转义序列来实现文本格式调整的方法,如''。值得注意的是,不同环境对ANSI转义的支持有所差异。
摘要由CSDN通过智能技术生成

How can I print output in bold in printf? "[1m testing bold" does not do anything.

String format = "%-20s %-15s %-20s %-15s %-10s";

System.out.printf(format, "Name", "Group_name", "Java_Prof_Level", "Cpr_Nr", "Gender", "[1m testing bold");

解决方案

You cannot print bold with Java System.out. It just streams to the standard output stream so, in principle, it is unformatted text only.

However, some software packages interpret special character sequences (the so-called ANSI escape sequences) to allow formatting.

Note that ANSI escape sequences start with an escape character, so you need to add that to your string also. (Try "\u001B[1m I am bold".)

Most Unix terminals interpret ANSI escape sequences by default. In old DOS times, you needed to use ANSI.SYS for the escape sequences to work.

In Windows and the Eclipse terminal the codes do not work.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值