读取配置文件工具demo
//读取配置文件
public class ResourcesUtils {
/*
* @description:根据属性获取文件名
*
* @param:propertyName文件的属性名
*
* @return:返回文件的属性值
* */
public static String getByName( String propertyName) {
String resultM = "";//返回结果 ResourceBundle bundle = ResourceBundle.getBundle("config");//获取config的熟悉 if (bundle.containsKey(propertyName)){//包含属性的key就返回相应的值
resultM = bundle.getString(propertyName);//设置返回值
} return resultM;
} /*
* @description:根据属性获取文件名
*
* @param:propertyName文件的属性名
*
* @return:返回文件的属性值
* */
public static String getByName( String propertyName, String propertyFile) {
String resultM = "";//返回结果 ResourceBundle bundle = ResourceBundle.getBundle(propertyFile);//获取config的熟悉 if (bundle.containsKey(propertyName)){//包含属性的key就返回相应的值
resultM = bundle.getString(propertyName);//设置返回值
} return resultM;
} }
读取配置文件工具demo的更多相关文章
- PropertiesUtil 读取配置文件工具类
package org.konghao.basic.util; import java.io.FileInputStream; import java.io.FileNotFoundException ...
- ConfigUtil读取配置文件工具类
ConfigUtil package com.sso.util; import java.io.FileNotFoundException; import java.io.IOException; i ...
- java读取配置文件方法以及工具类
第一种方式 : java工具类读取配置文件工具类 只是案例代码 抓取异常以后的代码自己处理 import java.io.FileNotFoundException; import java.io. ...
- properties + IO 读取配置文件
1.项目目录树 2.配置文件config.properties username = sushe password = sushe url = jdbc:mysql://172.16.100.10:3 ...
- 使用Properties去读取配置文件,并获得具体内容值
有时候,写了一个配置文件,需要知道读出来的内容对不对,我们需要测试一下,看看读出来的跟我们要的是不是一样.这里写了一个工具类,用来读取配置文件里面的内容. 一.使用Properties工具类来读取. ...
- //读取配置文件(属性文件)的工具类-ConfigManager
package com.pb.news.util; import java.io.IOException;import java.io.InputStream;import java.sql.Resu ...
- Java读取properties配置文件工具类
1. PropertyUtils.java package javax.utils; import java.io.InputStream; import java.util.Properties ...
- java 4种方式读取配置文件 + 修改配置文件
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[-] 方式一采用ServletContext读取读取配置文件的realpath然后通过文件流读取出来 方式二采用ResourceB ...
- Java 读取配置文件数据
Properties类 Properties类,是一个工具类,包含在java.util包中. 功能:可以保存持久的属性,通常用来读取配置文件或者属性文件,将文件中的数据读入properties对象中, ...
随机推荐
- Uva 11178 Morley's Theorem 向量旋转+求直线交点
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9 题意: Morlery定理是这样的:作三角形ABC每个 ...
- python 计算阶乘
# 用for循环计算 n! sum = n=int(input('请输入n=')) ,n+): ,-): sum *= j # sum=sum*j print('%d!=%3d' %(i,sum)) ...
- ng-grid
请查看官网:http://angular-ui.github.io/ui-grid/ 简单的使用: 总的来说我们 1.需要引入ng-grid-1.3.2.js 2.在html页面需要加入 class ...
- django使用bootstrap快速美化 admin后台
使用django-admin-bootstrappe快速美化后台 两步: 1.pip install django-admin-bootstrapped 安装应用 2.在setting.py里面添加 ...
- 用jersey写简单Restful接口
1.在myeclipse中新建一个Dynamic Web Project 2.下载jar包,地址在这里 3.restful service代码 package com.qy; import javax ...
- POJ-3744-概率dp+矩阵幂(分段)
Scout YYF I Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10214 Accepted: 2980 Desc ...
- 谈谈oracle里的join、left join、right join
create table l as select 'left_1' as str,'1' as v from dual union allselect 'left_2' ,'2' as v from ...
- MyBatise代码自动生成时候Oralce的number类型BigDecimal问题
使用MyBatise的代码自动生成工具时候,即便在配置文件中定义了 <javaTypeResolver> <property name="forceBigDecimals& ...
- [转载]LeetCode: Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...
- JS获取当前时间到30天之后的日期区间
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...