- 浏览: 101367 次
- 性别:
- 来自: 北京
-
最新评论
-
zgmws1978:
抄袭人家的吧
Extjs4.0 实现的后台管理模块 (包含前后台源码) -
luojia.smilence.:
这都下载不了,楼主更新一下链接吧。
史上最全的安卓android开发各种书籍文档资料整理包括书籍介绍和下载 -
429537044:
楼主你好,我想请问一下。 你在MyAccessDecision ...
Spring Security3.1 最新配置实例(spring权限管理) -
jiang_xiaohan:
在别处看过,下载过源码,但没架包的,hibernate我又不熟 ...
Spring Security3.1 最新配置实例(spring权限管理) -
yhr619:
写得挺好的
Spring Security3.1 最新配置实例(spring权限管理)
欢迎访问我的社区资源论坛http://www.javadt.com
【前言】众所周知,各式各样的Util类为我们提供了便利,也同时减少了我们对底层硬编码的时间,包括对字符串的操作,文件操作,反射的操作,泛型的操作,以及熟知的分页类,Json解析类、日期工具类等,这里把我开发的项目中用到过的工具类分享出来,都是经过多个项目的开发积累而锤炼出来的,提供给大家交流和学习。
【目录】
1.文件操作类 FileUtil
2.反射工具类 ReflectionUtil
3.泛型工具类 GenericsUtils
4.分页组件 Pagenation,PageUtil,Query
5.Http与servlet工具类 ServletUtils
6.日期工具类 DateUtil
7.Json解析类JsonUtil
8.编码与解码工具类 EncodeUtils
【代码片段】 由于篇幅有限,我只列举EncodeUtils、Pagenation,其他的大家下载附件即可查看。
/**
* 各种格式的编码加码工具类.
*
* 集成Commons-Codec,Commons-Lang及JDK提供的编解码方法.
*
* @author fisher
*/
public class EncodeUtils {
private static final String DEFAULT_URL_ENCODING = "UTF-8";
/**
* Hex编码.
*/
public static String hexEncode(byte[] input) {
return Hex.encodeHexString(input);
}
/**
* Hex解码.
*/
public static byte[] hexDecode(String input) {
try {
return Hex.decodeHex(input.toCharArray());
} catch (DecoderException e) {
throw new IllegalStateException("Hex Decoder exception", e);
}
}
/**
* Base64编码.
*/
public static String base64Encode(byte[] input) {
return new String(Base64.encodeBase64(input));
}
/**
* Base64编码, URL安全(将Base64中的URL非法字符如+,/=转为其他字符, 见RFC3548).
*/
public static String base64UrlSafeEncode(byte[] input) {
return Base64.encodeBase64URLSafeString(input);
}
/**
* Base64解码.
*/
public static byte[] base64Decode(String input) {
return Base64.decodeBase64(input);
}
/**
* URL 编码, Encode默认为UTF-8.
*/
public static String urlEncode(String input) {
try {
return URLEncoder.encode(input, DEFAULT_URL_ENCODING);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(
"Unsupported Encoding Exception", e);
}
}
/**
* URL 解码, Encode默认为UTF-8.
*/
public static String urlDecode(String input) {
try {
return URLDecoder.decode(input, DEFAULT_URL_ENCODING);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(
"Unsupported Encoding Exception", e);
}
}
/**
* Html 转码.
*/
public static String htmlEscape(String html) {
return StringEscapeUtils.escapeHtml(html);
}
/**
* Html 解码.
*/
public static String htmlUnescape(String htmlEscaped) {
return StringEscapeUtils.unescapeHtml(htmlEscaped);
}
/**
* Xml 转码.
*/
public static String xmlEscape(String xml) {
return StringEscapeUtils.escapeXml(xml);
}
/**
* Xml 解码.
*/
public static String xmlUnescape(String xmlEscaped) {
return StringEscapeUtils.unescapeXml(xmlEscaped);
}
}
/**
* @author fisher
* @description 分页查询对象
*/
public class Pagenation {
/** 是否有上一页 */
private boolean hasPrePage;
/** 是否有下一页 */
private boolean hasNextPage;
/** 每页记录数 */
private int everyPage;
/** 总页数 */
private int totalPage;
/** 当前页 数*/
private int currentPage;
/** 查询的开始行数*/
private int beginIndex;
public Pagenation(){
}
/** construct the page by everyPage
* @param everyPage
* */
public Pagenation(int everyPage){
this.everyPage = everyPage;
}
/** The whole constructor */
public Pagenation(boolean hasPrePage, boolean hasNextPage,
int everyPage, int totalPage,
int currentPage, int beginIndex) {
this.hasPrePage = hasPrePage;
this.hasNextPage = hasNextPage;
this.everyPage = everyPage;
this.totalPage = totalPage;
this.currentPage = currentPage;
this.beginIndex = beginIndex;
}
/**
* @return
* Returns the beginIndex.
*/
public int getBeginIndex() {
return beginIndex;
}
/**
* @param beginIndex
* The beginIndex to set.
*/
public void setBeginIndex(int beginIndex) {
this.beginIndex = beginIndex;
}
/**
* @return
* Returns the currentPage.
*/
public int getCurrentPage() {
return currentPage;
}
/**
* @param currentPage
* The currentPage to set.
*/
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
/**
* @return
* Returns the everyPage.
*/
public int getEveryPage(){
return everyPage;
}
/**
* @param everyPage
* The everyPage to set.
*/
public void setEveryPage(int everyPage) {
this.everyPage = everyPage;
}
/**
* @return
* Returns the hasNextPage.
*/
public boolean getHasNextPage(){
return hasNextPage;
}
/**
* @param hasNextPage
* The hasNextPage to set.
*/
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
/**
* @return
* Returns the hasPrePage.
*/
public boolean getHasPrePage() {
return hasPrePage;
}
/**
* @param hasPrePage
* The hasPrePage to set.
*/
public void setHasPrePage(boolean hasPrePage) {
this.hasPrePage = hasPrePage;
}
/**
* @return Returns the totalPage.
*
*/
public int getTotalPage() {
return totalPage;
}
/**
* @param totalPage
* The totalPage to set.
*/
public void setTotalPage(int totalPage){
this.totalPage = totalPage;
}
}
发表评论
-
史上最全的安卓android开发各种书籍文档资料整理包括书籍介绍和下载
2012-05-07 13:39 3088史上最全的安卓android开发各种书籍资料整理包括书籍 ... -
收集整理的oracle常用命令大全,解决oracle常见问题
2012-05-02 12:51 4757一、ORACLE的启动和关闭 1、在单机环境下 要 ... -
史上最全html及html5的学习资料文档收集整理包括介绍和下载
2012-04-28 09:21 3340下面是我收集整理的一些关于html5的相关文档和资料,有文档介 ... -
大量的javascript学习资料包括文档介绍下载和源码等
2012-04-26 09:49 1812下面是整理的大量关于javascript的一些资料文档等的介绍 ... -
Java中将中文姓名转换为拼音的简单实现
2012-04-25 09:15 3821以下是源代码:import net.sourceforge.p ... -
SQL语句使用大全,最常用的sql语句
2012-04-23 10:38 2766下列语句部分是Mssql语 ... -
史上最全的安卓android开发各种书籍文档资料整理包括书籍介绍和下载
2012-04-19 10:48 1077史上最全的安卓androi ... -
史上最全的Eclipse各种书籍资料整理包括书籍介绍和下载
2012-04-18 11:02 2543史上最全的Eclipse各种书籍资料整理包括书籍介绍和下 ... -
史上最全的jquery框架各种书籍整理包括书籍介绍和下载
2012-04-17 19:35 2077下面是我近期整理的几乎囊括了所有的jquery的教程和学 ... -
ajax框架prototype.js的各大文档整理积累文档的介绍和下载
2012-04-16 08:03 1208下面是整理的ajax框架prototype框架的一些文档 ... -
Microsoft Silverlight 4.0 介绍[PDF]
2012-04-15 18:55 1405Microsoft Silverlight 4.0 ... -
XML详细入门教程[PDF]
2012-04-15 18:40 2346本文档是一份很详 ... -
webQQ协议java的实现方法
2012-04-13 10:39 2374转载自:http://www.javadt.com/arti ... -
“为什么有钱有权的都移民了”?“贫贱不能移!”
2012-04-13 10:12 3转载自:“为什么有钱有权的都移民了”?“贫贱不能移!” ht ... -
JAVA 部署TOMCAT+IIS配置方法
2012-04-12 12:58 2772本文转载自:http://www.javadt.co ... -
android开发环境搭建以及配置方法[PDF]
2012-04-12 09:59 1067转载自:http://www.javadt.com/artic ... -
《JAVA代码规范》(六)通用代码格式 - 语句、SQL(2.9-2.10)
2012-04-12 21:40 1178转载自:http://www.javadt.c ... -
《JAVA代码规范》(五)通用代码格式 - 声明(2.8)
2012-04-11 20:56 883转载自:http://www.javadt.com/threa ... -
《JAVA代码规范》(四)通用代码格式 - 注释(2.7)
2012-04-11 20:55 1201转载自:http://www.javadt.c ... -
《JAVA代码规范》(三)通用代码格式 - 缩进、行长度、换行、空行、空格(2.2-2.6) ... ...
2012-04-11 20:54 8347转载自:http://www.javadt.com/threa ...
相关推荐
一般使用springjdbc、hibernate的sql查询,库获取到的数据都是List<Map<String, Object>>结果集,如果我们要转化为JavaBean,则需要做一系列的...此工程中就是解决List<Map<String, Object>>转化为JavaBean工具类实现
安全和 Windows 脚本宿主<br><br> CryptoAPI 工具<br> 对脚本进行签名<br> 软件限制策略<br> 签名验证策略<br> 验证脚本<br><br> 参考<br><br> XML 元素<br><br> <?job?> 元素<br> <?XML?> 元素<br> ...
一个基本的表格结构包括`<table>`、`<tr>`(行)、`<th>`(表头)和`<td>`(单元格)标签。例如: ```html <table> <tr> <th>姓名</th> <th>年龄</th> <th>城市</th> </tr> <tr> <td>张三</td> <td>25</td>...
RabbitMQClientUtil是MQ的测试工具类,他封装了fanout、direct、topic三种exchange模式,并包括发送数据和接收数据。 Test1、Test2是测试类 使用maven管理,在pom.xml文件中引入如下代码: <!-- Rabbitmq工具包...
String过滤敏感字
|—— |—— util —— 工具类 |—— model |—— |—— base —— pojo的父类 |—— |—— dao —— 持久层 |—— |—— domain —— 与数据库对应的实体类 |—— |—— dto —— 封装返回给前端的数据 |—— |——...
<br>【图书目录】<br>第1章 XML基础<br> 1.1 XML技术概述<br> 1.2 XML的基本语法<br> 1.3 XML的约束模式<br> 1.4 DTD<br> 1.5 DTD的语法细节<br> 1.6 XML Schema<br> 1.7 名称空间<br> 1.8 引入XML Schema...
<font face="Verdana">.net 文档生成工具</font>用于将<font face="Verdana">xml 文档注释</font>生成格式类似MSDN的HTML帮助文档,并编译为CHM文档。<span style="color: red"><strong>(下文中将该工具称为ADB,该...
在HTML中,我们可以使用各种标签来定义页面的不同部分,如`<header>`定义页眉,`<nav>`创建导航菜单,`<section>`分隔内容区域,`<article>`定义独立内容,`<footer>`表示页脚,以及`<form>`用于创建表单元素,使...
<a class="nav-link" href="#">首页<span class="sr-only">(current)</span></a> </li> <li class="nav-item"> <a class="nav-link" href="#">图书分类</a> </li> <li class="nav-item"> <a class="nav-link...
SDOAPI提供了对服务数据对象的一系列操作接口,而SDOUtil则是配合SDOAPI使用的实用工具类。这两个组件通常在Java开发中用于构建面向服务的架构(SOA)系统,尤其是在处理复杂数据交换时。本篇文章将深入探讨sdoapi、...
<br>/**********************************************/<br><br>点击右键——YYBuildProperty <br>或者 “工具”菜单——YYBuildProperty <br><br>自动生成如下属性代码:<br><br>/********************************...
<li><a href="#contact">联系我们</a></li> </ul> </nav> </header> <main> <section id="home"> <h1>欢迎来到我们的酒店</h1> <p>我们提供最舒适的住宿体验。</p> </section> <section id="services"> ...
<li><a href="#contact">联系我们</a></li> </ul> </nav> </header> <main> <section id="home"> <h2>欢迎来到橙子之家</h2> <p>这里是您探索橙子美味的最佳起点。</p> </section> <section id="menu"> <h2...
3. 文本元素:讲解如何使用<h1>到<h6>定义标题,<p>创建段落,<em>和<strong>强调文本。 4. 链接:教学如何创建<a>标签以实现页面间的链接和外部资源的引用。 5. 图像:说明<img>标签的用法,包括图片的来源、尺寸和...
接着,调用`Yaml.load()`方法将YAML数据解析为一个`Map<String, Object>`,这样我们就可以方便地通过键值对访问配置信息。最后,记得关闭输入流以释放资源。 在实际使用时,可以像下面这样调用`loadYaml`方法: ``...
<br><br>目录 : <br>第0章 认识Delphi <br><br>0-1 前言 <br>0-2 Delphi简介 <br>0-3 进入Delphi7 <br>0-4 退出Delphi <br><br>第1章 常用的窗口工具 <br><br>1-1 窗体(Form) <br>1-2 代码编辑器(Code Editor) ...
<br><br>此版本包含注册文件和简体中文语言安装包<br><br>Enhancements in PL/SQL Developer 7.1.5<br>======================================<br>- Fixed some access violations<br>- Inserting a record in the ...
在实际项目中,ExportExcel工具类可能还会包含其他功能,如自定义样式、合并单元格、添加图表等,以满足更复杂的需求。此外,你还需要确保正确处理异常,提供友好的错误提示。 总的来说,通过注解SpringMVC和...