编程小知识【java-0009】java常用开发库-Spring工具类
内置Resource类型
org.springframework.core.io.UrlResource:访问网络资源
org.springframework.core.io.ClassPathResource:访问类路径下资源
org.springframework.core.io.FileSystemResource:访问文件系统资源
org.springframework.web.context.support.ServletContextResource:访问相关Web应用程序根目录中的相对路径
org.springframework.core.io.InputStreamResource:输入流的Resource实现类,一般在没有特定的资源实现的时候使用
org.springframework.core.io.ByteArrayResource:字节数组的Resource实现类
org.springframework.core.io.support.EncodedResource :就是Resource加上encoding, 可以认为是有编码的资源。当您使用 Resource 实现类加载文件资源时,它默认采用操作系统的编码格式。如果文件资源采用了特殊的编码格式(如 UTF-8),则在读取资源内容时必须事先通过 EncodedResource 指定编码格式,否则将会产生中文乱码的问题。
org.springframework.core.io.VfsResource:在jboss里经常用到, 相应还有 工具类 VfsUtils
org.springframework.util.ResourceUtils:它支持“classpath:”和“file:”的地址前缀,它能够从指定的地址加载文件资源,常用方法:getFile()
常用工具类
org.springframework.util.Assert:断言工具类,通常用于数据合法性检查
org.springframework.web.context.support.WebApplicationContextUtils:获取spring应用的上下文,即 WebApplicationContext 对象
org.springframework.web.bind.ServletRequestUtils:web请求工具类,主要功能是用来从请求中解析被绑定的参数
org.springframework.util.FileCopyUtils:文件的拷贝处理,提供了许多一步式的静态操作方法,能够将文件内容拷贝到一个目标 byte[]、String 甚至一个输出流或输出文件中
org.springframework.core.io.support.PropertiesLoaderUtils:允许您直接通过基于类路径的文件地址加载属性资源
org.springframework.util.StringUtils:字符串工具类
org.springframework.util.CollectionUtils:集合工具类
org.springframework.util.NumberUtils:处理数字工具类
org.springframework.util.SerializationUtils:对象序列化与反序列化
org.springframework.util.DigestUtils:MD5加密
org.springframework.util.PatternMatchUtils:处理简单的匹配
org.springframework.util.PropertyPlaceholderHelper:处理占位符的替换
org.springframework.util.ReflectionUtils:反射常用工具方法. 有 findField, setField, getField, findMethod, invokeMethod等有用的方法