java,以粗体显示 [英] java, print in bold

查看:338
本文介绍了java,以粗体显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在printf中以粗体打印输出? [1m test bold不会做任何事情。

 字符串格式=%-20s%-15s%-20s%-15s%-10s; 

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


解决方案

>的System.out 。它只是流到标准输出流,所以原则上它只是未格式化的文本。然而,一些软件包解释特殊字符序列(即所谓的ANSI转义序列)以允许格式化。注意,ANSI转义序列以一个转义字符开头,所以你需要把它添加到你的字符串中。 (尝试\\\ [1m我是粗体的。)



大多数Unix终端默认解释ANSI转义序列。在旧的DOS时代,您需要使用 ANSI.SYS 来使转义序列正常工作。

在Windows和Eclipse终端中,代码无效。


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.

这篇关于java,以粗体显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆