代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Java
】
任意对象转化为JSON
作者:
/ 发布于
2011/1/14
/
479
<div><span style="color: #0000ff">import</span><span style="color: #000000"> java.beans.IntrospectionException; </span><span style="color: #0000ff">import</span><span style="color: #000000"> java.beans.Introspector; </span><span style="color: #0000ff">import</span><span style="color: #000000"> java.beans.PropertyDescriptor; </span><span style="color: #0000ff">import</span><span style="color: #000000"> java.math.BigDecimal; </span><span style="color: #0000ff">import</span><span style="color: #000000"> java.math.BigInteger; </span><span style="color: #0000ff">import</span><span style="color: #000000"> java.util.List; </span><span style="color: #0000ff">import</span><span style="color: #000000"> java.util.Map; </span><span style="color: #0000ff">import</span><span style="color: #000000"> java.util.Set; </span><span style="color: #008000">/**</span><span style="color: #008000"> * 序列化对象为JSON格式 遵循JSON组织公布标准 * * @date 2008/05/07 * </span><span style="color: #808080">@version</span><span style="color: #008000"> 1.0.0 </span><span style="color: #008000">*/</span><span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">class</span><span style="color: #000000"> Json { </span><span style="color: #008000">/**</span><span style="color: #008000"> Commons Logging instance. </span><span style="color: #008000">*/</span><span style="color: #000000"> </span><span style="color: #0000ff">private</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> org.apache.commons.logging.Log log </span><span style="color: #000000">=</span><span style="color: #000000"> org.apache.commons.logging.LogFactory.getLog(Json.</span><span style="color: #0000ff">class</span><span style="color: #000000">); </span><span style="color: #008000">/**</span><span style="color: #008000"> * </span><span style="color: #808080">@param</span><span style="color: #008000"> obj 任意对象 * </span><span style="color: #808080">@return</span><span style="color: #008000"> String </span><span style="color: #008000">*/</span><span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String object2json(Object obj) { StringBuilder json </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuilder(); </span><span style="color: #0000ff">if</span><span style="color: #000000"> (obj </span><span style="color: #000000">==</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">) { json.append(</span><span style="color: #000000">"</span><span style="color: #000000">\"\"</span><span style="color: #000000">"</span><span style="color: #000000">); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="color: #0000ff">if</span><span style="color: #000000"> (obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> String </span><span style="color: #000000">||</span><span style="color: #000000"> obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Integer </span><span style="color: #000000">||</span><span style="color: #000000"> obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Float </span><span style="color: #000000">||</span><span style="color: #000000"> obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Boolean </span><span style="color: #000000">||</span><span style="color: #000000"> obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Short </span><span style="color: #000000">||</span><span style="color: #000000"> obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Double </span><span style="color: #000000">||</span><span style="color: #000000"> obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Long </span><span style="color: #000000">||</span><span style="color: #000000"> obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> BigDecimal </span><span style="color: #000000">||</span><span style="color: #000000"> obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> BigInteger </span><span style="color: #000000">||</span><span style="color: #000000"> obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Byte) { json.append(</span><span style="color: #000000">"</span><span style="color: #000000">\"</span><span style="color: #000000">"</span><span style="color: #000000">).append(string2json(obj.toString())).append(</span><span style="color: #000000">"</span><span style="color: #000000">\"</span><span style="color: #000000">"</span><span style="color: #000000">); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="color: #0000ff">if</span><span style="color: #000000"> (obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Object[]) { json.append(array2json((Object[]) obj)); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="color: #0000ff">if</span><span style="color: #000000"> (obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> List) { json.append(list2json((List</span><span style="color: #000000"><?></span><span style="color: #000000">) obj)); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="color: #0000ff">if</span><span style="color: #000000"> (obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Map) { json.append(map2json((Map</span><span style="color: #000000"><?</span><span style="color: #000000">, </span><span style="color: #000000">?></span><span style="color: #000000">) obj)); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> </span><span style="color: #0000ff">if</span><span style="color: #000000"> (obj </span><span style="color: #0000ff">instanceof</span><span style="color: #000000"> Set) { json.append(set2json((Set</span><span style="color: #000000"><?></span><span style="color: #000000">) obj)); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> { json.append(bean2json(obj)); } </span><span style="color: #0000ff">return</span><span style="color: #000000"> json.toString(); } </span><span style="color: #008000">/**</span><span style="color: #008000"> * </span><span style="color: #808080">@param</span><span style="color: #008000"> bean bean对象 * </span><span style="color: #808080">@return</span><span style="color: #008000"> String </span><span style="color: #008000">*/</span><span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String bean2json(Object bean) { StringBuilder json </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuilder(); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">{</span><span style="color: #000000">"</span><span style="color: #000000">); PropertyDescriptor[] props </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">; </span><span style="color: #0000ff">try</span><span style="color: #000000"> { props </span><span style="color: #000000">=</span><span style="color: #000000"> Introspector.getBeanInfo(bean.getClass(), Object.</span><span style="color: #0000ff">class</span><span style="color: #000000">).getPropertyDescriptors(); } </span><span style="color: #0000ff">catch</span><span style="color: #000000"> (IntrospectionException e) { } </span><span style="color: #0000ff">if</span><span style="color: #000000"> (props </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">) { </span><span style="color: #0000ff">for</span><span style="color: #000000"> (</span><span style="color: #0000ff">int</span><span style="color: #000000"> i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> props.length; i</span><span style="color: #000000">++</span><span style="color: #000000">) { </span><span style="color: #0000ff">try</span><span style="color: #000000"> { String name </span><span style="color: #000000">=</span><span style="color: #000000"> object2json(props[i].getName()); String value </span><span style="color: #000000">=</span><span style="color: #000000"> object2json(props[i].getReadMethod().invoke(bean)); json.append(name); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">:</span><span style="color: #000000">"</span><span style="color: #000000">); json.append(value); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">"</span><span style="color: #000000">); } </span><span style="color: #0000ff">catch</span><span style="color: #000000"> (Exception e) { } } json.setCharAt(json.length() </span><span style="color: #000000">-</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">, </span><span style="color: #000000">'</span><span style="color: #000000">}</span><span style="color: #000000">'</span><span style="color: #000000">); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> { json.append(</span><span style="color: #000000">"</span><span style="color: #000000">}</span><span style="color: #000000">"</span><span style="color: #000000">); } </span><span style="color: #0000ff">return</span><span style="color: #000000"> json.toString(); } </span><span style="color: #008000">/**</span><span style="color: #008000"> * </span><span style="color: #808080">@param</span><span style="color: #008000"> list list对象 * </span><span style="color: #808080">@return</span><span style="color: #008000"> String </span><span style="color: #008000">*/</span><span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String list2json(List</span><span style="color: #000000"><?></span><span style="color: #000000"> list) { StringBuilder json </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuilder(); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">[</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">if</span><span style="color: #000000"> (list </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&&</span><span style="color: #000000"> list.size() </span><span style="color: #000000">></span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">) { </span><span style="color: #0000ff">for</span><span style="color: #000000"> (Object obj : list) { json.append(object2json(obj)); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">"</span><span style="color: #000000">); } json.setCharAt(json.length() </span><span style="color: #000000">-</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">, </span><span style="color: #000000">'</span><span style="color: #000000">]</span><span style="color: #000000">'</span><span style="color: #000000">); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> { json.append(</span><span style="color: #000000">"</span><span style="color: #000000">]</span><span style="color: #000000">"</span><span style="color: #000000">); } </span><span style="color: #0000ff">return</span><span style="color: #000000"> json.toString(); } </span><span style="color: #008000">/**</span><span style="color: #008000"> * </span><span style="color: #808080">@param</span><span style="color: #008000"> array 对象数组 * </span><span style="color: #808080">@return</span><span style="color: #008000"> String </span><span style="color: #008000">*/</span><span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String array2json(Object[] array) { StringBuilder json </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuilder(); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">[</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">if</span><span style="color: #000000"> (array </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&&</span><span style="color: #000000"> array.length </span><span style="color: #000000">></span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">) { </span><span style="color: #0000ff">for</span><span style="color: #000000"> (Object obj : array) { json.append(object2json(obj)); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">"</span><span style="color: #000000">); } json.setCharAt(json.length() </span><span style="color: #000000">-</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">, </span><span style="color: #000000">'</span><span style="color: #000000">]</span><span style="color: #000000">'</span><span style="color: #000000">); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> { json.append(</span><span style="color: #000000">"</span><span style="color: #000000">]</span><span style="color: #000000">"</span><span style="color: #000000">); } </span><span style="color: #0000ff">return</span><span style="color: #000000"> json.toString(); } </span><span style="color: #008000">/**</span><span style="color: #008000"> * </span><span style="color: #808080">@param</span><span style="color: #008000"> map map对象 * </span><span style="color: #808080">@return</span><span style="color: #008000"> String </span><span style="color: #008000">*/</span><span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String map2json(Map</span><span style="color: #000000"><?</span><span style="color: #000000">, </span><span style="color: #000000">?></span><span style="color: #000000"> map) { StringBuilder json </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuilder(); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">{</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">if</span><span style="color: #000000"> (map </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&&</span><span style="color: #000000"> map.size() </span><span style="color: #000000">></span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">) { </span><span style="color: #0000ff">for</span><span style="color: #000000"> (Object key : map.keySet()) { json.append(object2json(key)); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">:</span><span style="color: #000000">"</span><span style="color: #000000">); json.append(object2json(map.get(key))); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">"</span><span style="color: #000000">); } json.setCharAt(json.length() </span><span style="color: #000000">-</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">, </span><span style="color: #000000">'</span><span style="color: #000000">}</span><span style="color: #000000">'</span><span style="color: #000000">); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> { json.append(</span><span style="color: #000000">"</span><span style="color: #000000">}</span><span style="color: #000000">"</span><span style="color: #000000">); } </span><span style="color: #0000ff">return</span><span style="color: #000000"> json.toString(); } </span><span style="color: #008000">/**</span><span style="color: #008000"> * </span><span style="color: #808080">@param</span><span style="color: #008000"> set 集合对象 * </span><span style="color: #808080">@return</span><span style="color: #008000"> String </span><span style="color: #008000">*/</span><span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String set2json(Set</span><span style="color: #000000"><?></span><span style="color: #000000"> set) { StringBuilder json </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuilder(); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">[</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">if</span><span style="color: #000000"> (set </span><span style="color: #000000">!=</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000"> </span><span style="color: #000000">&&</span><span style="color: #000000"> set.size() </span><span style="color: #000000">></span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">) { </span><span style="color: #0000ff">for</span><span style="color: #000000"> (Object obj : set) { json.append(object2json(obj)); json.append(</span><span style="color: #000000">"</span><span style="color: #000000">,</span><span style="color: #000000">"</span><span style="color: #000000">); } json.setCharAt(json.length() </span><span style="color: #000000">-</span><span style="color: #000000"> </span><span style="color: #000000">1</span><span style="color: #000000">, </span><span style="color: #000000">'</span><span style="color: #000000">]</span><span style="color: #000000">'</span><span style="color: #000000">); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> { json.append(</span><span style="color: #000000">"</span><span style="color: #000000">]</span><span style="color: #000000">"</span><span style="color: #000000">); } </span><span style="color: #0000ff">return</span><span style="color: #000000"> json.toString(); } </span><span style="color: #008000">/**</span><span style="color: #008000"> * </span><span style="color: #808080">@param</span><span style="color: #008000"> s 参数 * </span><span style="color: #808080">@return</span><span style="color: #008000"> String </span><span style="color: #008000">*/</span><span style="color: #000000"> </span><span style="color: #0000ff">public</span><span style="color: #000000"> </span><span style="color: #0000ff">static</span><span style="color: #000000"> String string2json(String s) { </span><span style="color: #0000ff">if</span><span style="color: #000000"> (s </span><span style="color: #000000">==</span><span style="color: #000000"> </span><span style="color: #0000ff">null</span><span style="color: #000000">) </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="color: #000000">""</span><span style="color: #000000">; StringBuilder sb </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #0000ff">new</span><span style="color: #000000"> StringBuilder(); </span><span style="color: #0000ff">for</span><span style="color: #000000"> (</span><span style="color: #0000ff">int</span><span style="color: #000000"> i </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; i </span><span style="color: #000000"><</span><span style="color: #000000"> s.length(); i</span><span style="color: #000000">++</span><span style="color: #000000">) { </span><span style="color: #0000ff">char</span><span style="color: #000000"> ch </span><span style="color: #000000">=</span><span style="color: #000000"> s.charAt(i); </span><span style="color: #0000ff">switch</span><span style="color: #000000"> (ch) { </span><span style="color: #0000ff">case</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">"</span><span style="color: #000000">'</span><span style="color: #000000">: sb.append(</span><span style="color: #000000">"</span><span style="color: #000000">\\\"</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">break</span><span style="color: #000000">; </span><span style="color: #0000ff">case</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">\\</span><span style="color: #000000">'</span><span style="color: #000000">: sb.append(</span><span style="color: #000000">"</span><span style="color: #000000">\\\\</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">break</span><span style="color: #000000">; </span><span style="color: #0000ff">case</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">\b</span><span style="color: #000000">'</span><span style="color: #000000">: sb.append(</span><span style="color: #000000">"</span><span style="color: #000000">\\b</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">break</span><span style="color: #000000">; </span><span style="color: #0000ff">case</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">\f</span><span style="color: #000000">'</span><span style="color: #000000">: sb.append(</span><span style="color: #000000">"</span><span style="color: #000000">\\f</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">break</span><span style="color: #000000">; </span><span style="color: #0000ff">case</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">\n</span><span style="color: #000000">'</span><span style="color: #000000">: sb.append(</span><span style="color: #000000">"</span><span style="color: #000000">\\n</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">break</span><span style="color: #000000">; </span><span style="color: #0000ff">case</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">\r</span><span style="color: #000000">'</span><span style="color: #000000">: sb.append(</span><span style="color: #000000">"</span><span style="color: #000000">\\r</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">break</span><span style="color: #000000">; </span><span style="color: #0000ff">case</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">\t</span><span style="color: #000000">'</span><span style="color: #000000">: sb.append(</span><span style="color: #000000">"</span><span style="color: #000000">\\t</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">break</span><span style="color: #000000">; </span><span style="color: #0000ff">case</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">/</span><span style="color: #000000">'</span><span style="color: #000000">: sb.append(</span><span style="color: #000000">"</span><span style="color: #000000">\\/</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">break</span><span style="color: #000000">; </span><span style="color: #0000ff">default</span><span style="color: #000000">: </span><span style="color: #0000ff">if</span><span style="color: #000000"> (ch </span><span style="color: #000000">>=</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">\u0000</span><span style="color: #000000">'</span><span style="color: #000000"> </span><span style="color: #000000">&&</span><span style="color: #000000"> ch </span><span style="color: #000000"><=</span><span style="color: #000000"> </span><span style="color: #000000">'</span><span style="color: #000000">\u001F</span><span style="color: #000000">'</span><span style="color: #000000">) { String ss </span><span style="color: #000000">=</span><span style="color: #000000"> Integer.toHexString(ch); sb.append(</span><span style="color: #000000">"</span><span style="color: #000000">\\u</span><span style="color: #000000">"</span><span style="color: #000000">); </span><span style="color: #0000ff">for</span><span style="color: #000000"> (</span><span style="color: #0000ff">int</span><span style="color: #000000"> k </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">; k </span><span style="color: #000000"><</span><span style="color: #000000"> </span><span style="color: #000000">4</span><span style="color: #000000"> </span><span style="color: #000000">-</span><span style="color: #000000"> ss.length(); k</span><span style="color: #000000">++</span><span style="color: #000000">) { sb.append(</span><span style="color: #000000">'</span><span style="color: #000000">0</span><span style="color: #000000">'</span><span style="color: #000000">); } sb.append(ss.toUpperCase()); } </span><span style="color: #0000ff">else</span><span style="color: #000000"> { sb.append(ch); } } } </span><span style="color: #0000ff">return</span><span style="color: #000000"> sb.toString(); } } </span></div>
试试其它关键字
JSON
同语言下
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
贡献的其它代码
Label
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3