-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchapter.apache.xml
More file actions
111 lines (97 loc) · 2.52 KB
/
chapter.apache.xml
File metadata and controls
111 lines (97 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?xml version="1.0" encoding="UTF-8"?>
<chapter id="index"><?dbhtml dir="org/apache" ?>
<title>Apache HttpComponents</title>
<section id="org.apache.commons.lang3">
<title>org.apache.commons.lang3</title>
<section id="StringEscapeUtils">
<title>HTML 标签处理</title>
<programlisting>
<![CDATA[
package cn.netkiller.apache.lang;
import org.apache.commons.lang3.StringEscapeUtils;
@SuppressWarnings("deprecation")
public class LangTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
String html = "<span>Neo's book</span>";
String encode = StringEscapeUtils.escapeHtml4(html);
String decode = StringEscapeUtils.unescapeHtml4(encode);
System.out.println(encode);
System.out.println(decode);
}
}
]]>
</programlisting>
</section>
<section id="StringUtils">
<title>StringUtils.join 使用特定字符链接字符串</title>
<para>下面例子使用逗号链接字符串</para>
<programlisting>
<![CDATA[
org.apache.commons.lang.StringUtils.join(arraylist, ',')
]]>
</programlisting>
</section>
<section id="RandomStringUtils">
<title>RandomStringUtils</title>
<programlisting>
<![CDATA[
String project = RandomStringUtils.randomAlphanumeric(10);
System.out.print(project);
]]>
</programlisting>
<para>随机输出 ASCII</para>
<screen>
<![CDATA[
System.out.println(RandomStringUtils.randomAscii(10));
]]>
</screen>
<para>随机输出数字</para>
<screen>
<![CDATA[
System.out.println(RandomStringUtils.randomNumeric(10));
]]>
</screen>
<para>指定字符串随机输出</para>
<screen>
<![CDATA[
String project = RandomStringUtils.random(10, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").toString();
System.out.println(project);
]]>
</screen>
</section>
</section>
<section id="commons-text">
<title>commons-text</title>
<screen>
<![CDATA[
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.6</version>
</dependency>
]]>
</screen>
<section>
<title>禁止转译 json</title>
<programlisting>
<![CDATA[
package cn.netkiller.test;
import org.apache.commons.text.StringEscapeUtils;
public class TestJson {
public static void main(String[] args) {
System.out.println(StringEscapeUtils.escapeJson("{\"name\":\"Neo\"}"));
}
}
]]>
</programlisting>
<para>输出</para>
<screen>
<![CDATA[
{\"name\":\"Neo\"}
]]>
</screen>
</section>
</section>
§ion.apache.httpclient.xml;
</chapter>