Sprint读取配置文件内容格式的String
2017-07-11 09:15
393 查看
package unit.test; import java.io.IOException; import java.util.Properties; import org.junit.Test; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.support.PropertiesLoaderUtils; public class StringPropertyLoadTest { @Test public void testLoad(){ String protertryStr = "spring.redis.database=0\n"+ "spring.redis.host=localhost\n"+ "spring.redis.port=8080\n"+ "spring.redis.password=\n"+ "#this is comment! \n"+ "spring.redis.timeout=0\n"+ "spring.redis.pool.max-active=8 #abcd \n"+ "spring.redis.pool.max-wait=-1\n"+ "spring.redis.pool.max-idle=8\n"+ "spring.redis.pool.min-idle=0\n"; ByteArrayResource resource = new ByteArrayResource(protertryStr.getBytes(), protertryStr); try { Properties properties =PropertiesLoaderUtils.loadProperties(resource); properties.entrySet().forEach(p ->{ System.out.println(p.getKey()+"="+p.getValue()); }); } catch (IOException e) { e.printStackTrace(); } } }
相关文章推荐
- 利用GetPrivateProfileString读取配置文件(.ini)
- 利用GetPrivateProfileString读取配置文件(.ini)
- DOS批处理:读取配置文件,格式 与 程序,例子
- “使用了CFileDialog后就不能使用GetPrivateProfileString来读取配置文件”的解决办法
- GetPrivateProfileString读取INI配置文件信息
- c/c++: 读取配置文件(文本)内容的简单实现
- 编写一个文件,读取 src 下面day12包 下面的my.properties 文件,文件内容如下, className=day12.User 结合 IO、反射知识,完成 配置文件中对象的创建和方法调用。并编写方法,列举出 Student 类中所有的属性、
- 读取配置文件GetProfileString(linux版)
- 读取INI配置文件内容(头文件head)
- 利用GetPrivateProfileString读取配置文件(.ini)
- 读取本机的Java运行环境和相关配置文件的内容 推荐
- 读取INI配置文件GetProfileString和GetPrivateProfileString参数说明和示例
- c# winform 读取ini配置文件信息内容
- 读取INI配置文件内容(源文件C)
- 利用GetPrivateProfileString读取配置文件
- 利用GetPrivateProfileString读取配置文件(.ini)
- 利用GetPrivateProfileString读取配置文件(.ini)
- 每日一石--读取配置文件中的内容小实例
- 用GetPrivateProfileString读取配置文件(.ini)
- DOS批处理:读取配置文件,格式 与 程序,例子