我有字符串数据(动态),其中包含以下格式的以下信息:
UNI_ID ABCD-211
Title Enrolled With 202
Enrolle Enrolle IA
Written Mr. R D
Received by Anny
Received 18 May 2012 05:32:07
Billing address:
Email abc@abc.com
Phone number 0049 xxxx 3xxxxxx
Department N/A
Organization N/A
Address line 1 12 c
Address line 2 VN
City London
State/Province GB
Zip/Postcode xyz
Country
UK
Order details:
OrderNumber 1232120000
Order date 18 May 2012
Purchase order no
Currency GBP
Product amount � 9.00
Admin charge � 50.00
VAT amount � 11.21
Total amount � 70.21
在上述信息中,即使国家/地区也没有很好地对齐。我需要在HTML文件中使用此String。对齐不合适?
所以我使用StringEscapeUtils.escapeJava
,如下所示:
String details6 = StringEscapeUtils.escapeJava(
data.replaceAll("\n\n\n", "<br><br>")
.replaceAll("\n\n\n\n", "<br><br>")
.replaceAll("\n\n", "<br><br>")
.replaceAll("\n", "<br>")
.replaceAll("\t", " ")
.replaceAll("\t ", " ")
.replace("\r", "")
.replace("∩┐╜", "€"));
在下面的渲染中,以HTML格式输出HTML:
UAN_ID ABCD-211
Title Enrolled With 202
Enrolle Enrolle IA
Written Mr. R D
Received by Anny
Received 18 May 2012 05:32:07
Billing address:
Email abc@abc.com
Phone number 0049 xxxx 3xxxxxx
Department N\/A
Organization N\/A
Address line 1 12 c
Address line 2 VN
City London
State/Province GB
State\/Province MA
Zip\/Postcode xyz
Country
UK
Order details:
OrderNumber 1232120000
Order date 18 May 2012
Purchase order no
Currency GBP
Product amount \uFFFD 9.00
Admin charge \uFFFD 50.00
VAT amount \uFFFD 11.21
Total amount \uFFFD 70.21
有什么方法可以对齐上面的字段吗?