- 浏览: 3364746 次
- 性别:
- 来自: 珠海
文章分类
- 全部博客 (1633)
- Java (250)
- Android&HTML5 (111)
- Struts (10)
- Spring (236)
- Hibernate&MyBatis (115)
- SSH (49)
- jQuery插件收集 (55)
- Javascript (145)
- PHP (77)
- REST&WebService (18)
- BIRT (27)
- .NET (7)
- Database (105)
- 设计模式 (16)
- 自动化和测试 (19)
- Maven&Ant (43)
- 工作流 (36)
- 开源应用 (156)
- 其他 (16)
- 前台&美工 (119)
- 工作积累 (0)
- OS&Docker (83)
- Python&爬虫 (28)
- 工具软件 (157)
- 问题收集 (61)
- OFbiz (6)
- noSQL (12)
最新评论
-
HEZR曾嶸:
你好博主,这个不是很理解,能解释一下嘛//左边+1,上边+1, ...
java 两字符串相似度计算算法 -
天使建站:
写得不错,可以看这里,和这里的这篇文章一起看,有 ...
jquery 遍历对象、数组、集合 -
xue88ming:
很有用,谢谢
@PathVariable映射出现错误: Name for argument type -
jnjeC:
厉害,困扰了我很久
MyBatis排序时使用order by 动态参数时需要注意,用$而不是# -
TopLongMan:
非常好,很实用啊。。
PostgreSQL递归查询实现树状结构查询
Properties detailProps = loadProperties("com/test.properties");
protected Properties loadProperties(String resource) throws IOException { Properties props = new Properties(); InputStream is = null; try { is = ResourceHelper.getClassPathResourceAsInputStream(resource); if (is != null) { propertiesPersister.load(props, new InputStreamReader(is, "UTF-8")); } } finally { IOUtils.closeQuietly(is); } return props; }
package com.tools; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.util.ResourceUtils; /** * 资源操作工具类 * * @author ourenyang * */ public class ResourceHelper { /** * 在指定类所在包下查找指定的资源文件,并转换成InputStream * * @param file * @param clazz * @return * @throws IOException */ public static InputStream getResourceInPackage(String file, Class<?> clazz) throws IOException { StringBuilder path = new StringBuilder(clazz.getPackage().getName().replace('.', '/')); if (file.charAt(0) != '/') { path.append('/'); } path.append(file); Resource res = new ClassPathResource(path.toString()); return res.getInputStream(); } /** * 在指定类所在包下查找指定的资源文件,并转换成InputStream * * @param file * @param clazz * @return * @throws IOException */ public static Reader getResourceInPackageAsReader(String file, Class<?> clazz) throws IOException { StringBuilder path = new StringBuilder(clazz.getPackage().getName().replace('.', '/')); if (file.charAt(0) != '/') { path.append('/'); } path.append(file); Resource res = new ClassPathResource(path.toString()); return new InputStreamReader(res.getInputStream()); } /** * 从Class路径中获取指定资源文件,并转换成InputStream * * @param path * @return * @throws IOException */ public static InputStream getClassPathResourceAsInputStream(String path) throws IOException { Resource res = new ClassPathResource(path); return res.getInputStream(); } /** * 获取指定资源文件,并转换成InputStream,资源文件名规则见Spring * * @param path * @return * @throws IOException */ public static InputStream getResourceAsInputStream(String path) throws IOException { File file = ResourceUtils.getFile(path); return new FileInputStream(file); } /** * 从Class路径中获取指定资源文件,并转换成Reader * * @param path * @return * @throws IOException */ public static Reader getClassPathResourceAsReader(String path) throws IOException { Resource res = new ClassPathResource(path); InputStream is = res.getInputStream(); return new InputStreamReader(is); } /** * 获取指定资源文件,并转换成Reader,资源文件名规则见Spring * * @param path * @return * @throws IOException */ public static Reader getResourceAsReader(String path) throws IOException { File file = ResourceUtils.getFile(path); return new FileReader(file); } }
发表评论
-
Java Comparable和Comparator
2016-06-26 08:52 657http://my.oschina.net/android52 ... -
Java集合框架之fastutil & koloboke
2016-06-23 14:04 2411Java集合框架之fastutil http://rensan ... -
ehcache 分布式支持
2016-06-05 22:26 1057原文 http://my.oschina.net/glenxu ... -
Intellij IDEA插件开发入门
2016-05-26 11:42 2843原文: http://blog.csdn.net/dc_726 ... -
阿里巴巴Druid数据源的配置与使用
2016-05-24 17:42 1499http://my.oschina.net/wjme/blog ... -
mysql中间件研究(Atlas,cobar,TDDL), 分库分表插件
2016-05-09 14:15 3391http://www.guokr.com/blog/47576 ... -
Java集合: Queue和Deque
2016-05-09 09:49 1828Queue http://my.oschina.net/kev ... -
使用gzip优化web应用(filter实现)
2016-05-07 01:45 1001使用gzip优化web应用(filter实现) http:// ... -
Byteman 3.0.5 发布,Java 字节码注入工具
2016-04-23 10:29 1726Byteman 3.0.5 发布,Java 字 ... -
RandomStringUtils的说明和生成随机汉字
2016-04-20 15:21 1319更多参考: http://my.oschina.net/wil ... -
通过IP地址获取地理位置
2016-04-20 15:19 856http://my.oschina.net/githubhty ... -
Java编程中使用正则表达式过滤非数字字符串
2016-04-14 13:51 1675/** * * @param str ... -
非对称加密DH算法,DH代码实现
2016-04-13 11:33 1316RSA算法原理(一)http:// ... -
企业支付宝账号开发接口教程
2016-03-31 14:52 1196企业支付宝账号开发接口教程--JAVA-UTF-8(实际操作- ... -
java double类型数据操作工具类
2016-03-28 17:36 1177http://my.oschina.net/yxwblog/b ... -
double转换到BigDecimal
2016-03-28 17:11 1506BigDecimal b = new BigDecimal(d ... -
Java 生成好看的验证码
2016-03-23 10:52 3307http://www.oschina.net/code/sni ... -
Linux环境安装配置Swftools
2016-03-22 21:01 1054http://tetop.blog.51cto.com/188 ... -
java压缩与解压缩文件
2016-03-20 22:03 1431http://www.oschina.net/code/sni ... -
java图像压缩
2016-03-19 23:20 919http://my.oschina.net/686991/bl ...
相关推荐
spring读取配置不同目录下的配置文件,使用ClassPathXmlApplicationContext与FileSystemXmlApplicationContext
主要给大家介绍了Spring Batch读取txt文件并写入数据库的方法,SpringBatch 是一个轻量级、全面的批处理框架。这里我们用它来实现文件的读取并将读取的结果作处理,处理之后再写入数据库中的功能。需要的朋友可以...
NULL 博文链接:https://konghaibo.iteye.com/blog/430146
spring读取properties.
我们使用Spring Boot编写多个模块开发时,我们希望各个模块使用各自的配置文件,避免将整个项目的配置文件都写在一起,从而降低各个模块之间的耦合度。
NULL 博文链接:https://songwensheng.iteye.com/blog/629578
主要介绍了Spring读取配置文件属性实现方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Spring源码分析:配置文件读取流程 - ImportNew
实现Springboot读取本地json文件
使用Spring配置文件实现AOP
Spring 读取properties文件key+value方式.rar
主要介绍了spring boot读取Excel操作,结合实例形式详细分析了spring boot解析、读取Excel相关操作技巧,需要的朋友可以参考下
在非spring注解类中使用spring容器中的bean_普通类中使用yml配置文件中的配置信息,在大数据采集项目中用到的,已经测试过了
主要介绍了Spring Boot读取resources目录文件方法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
本资源对spring-boot中的核心配置文件进行详细介绍,具体内容参考博客:http://blog.csdn.net/pengjunlee/article/details/79640361,包括:核心配置文件介绍,读取配置,动态加载配置等。
spring读取properties配置文件的key值。
主要介绍了Spring如何使用PropertyPlaceholderConfigurer读取文件,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Spring Boot读取配置文件常用方式
MinIO 是一个基于Apache License v2.0开源协议的对象存储服务。它兼容亚马逊S3云存储服务接口,非常适合于存储大容量非结构化的数据,例如图片、视频、日志文件、备份数据和...Spring boot整合MinIO客户端实现文件管理
本篇文章主要介绍了spring batch 读取多个文件数据导入数据库示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧