java读取属性配置文件工具类
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
*
* 类: ProUtil <br>
* 描述: 属性配置文件读取类 <br>
* 作者: poseidon<br>
* 版本: 1.0<br>
* 时间: 2015-7-17 上午09:20:17
*/
public class ProUtil {
/* 私有构造方法,防止被实例化 */
private ProUtil (){};
public static Properties propertie = null;
static {
propertie = new Properties();
InputStream inputStream = ProUtil.class.getResourceAsStream("/config.properties");
//解决中文乱码
BufferedReader buff = new BufferedReader(new InputStreamReader(inputStream));
try {
propertie.load(buff);
inputStream.close();
} catch (IOException e) {
}
}
public static void main(String[] args) {
System.out.println("--->"+ProUtil.propertie.get("username")); //username
}
}
IT技术和行业交流群 417691667
java读取属性配置文件工具类的更多相关文章
- Java读取properties配置文件工具类
1. PropertyUtils.java package javax.utils; import java.io.InputStream; import java.util.Properties ...
- Java读取属性配置文件-properties
在项目开发中,我们难免将一些可变的参数放在程序以外,作为一个单独的文件,即配置文件,这样方便项目在不同的使用环境部署时.或者说需要不同时,可以通过简单配置这些程序以外的文件来修改程序里的变量. 常用的 ...
- Java读取properties文件工具类并解决控制台中文乱码
1.建立properts文件(error.message.properties) HTTP201= 请求成功并且服务器创建了新的资源 2.在spring-mvc.xml文件(applicationCo ...
- java读取properties的工具类PropertiesUtil
package org.properties.util; import java.io.FileInputStream; import java.io.FileOutputStream; import ...
- 开发读取.properties 配置文件工具类PropertiesUtil
import java.io.IOException; import java.io.InputStream; import java.util.Properties; import org.juni ...
- java读取.txt文件工具类FileUtiles
public class FileUtils { private static final String ENCODING = "UTF-8";//编码方式 /** * 获取文件的 ...
- java读取properties配置文件总结
java读取properties配置文件总结 在日常项目开发和学习中,我们不免会经常用到.propeties配置文件,例如数据库c3p0连接池的配置等.而我们经常读取配置文件的方法有以下两种: (1) ...
- 读取Config文件工具类 PropertiesConfig.java
package com.util; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io ...
- Java加载Properties配置文件工具类
Java加载Properties配置文件工具类 import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; ...
随机推荐
- Spring官网改版后下载
Spring官网改版后找了好久都没有找到直接下载Jar包的链接,下面汇总些网上提供的方法,亲测可用. 1.直接输入地址,改相应版本即可:http://repo.springsource.org/lib ...
- JVM内存配置详解
前段时间在一个项目的性能测试中又发生了一次OOM(Out of swap sapce),情形和以前网店版的那次差不多,比上次更奇怪的是,此次搞了几天之后啥都没调整系统就自动好了,死活没法再重现之前的O ...
- 开发Portlet第一步:如何基于Crystal开发静态Portlet?
当团队需要基于Crystal开发Porltet时,分为以下三部: 基于Crystal开发静态Portlet 基于将静态Portlet修改为基于测试数据的动态Portlet 将动态Portlet与动态数 ...
- node http 服务
var http = require("http") http.createServer(function(req,res){ res.writeHead(200,{"C ...
- 选项卡 tab切换
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 九校联考 终&启
one term's ending... class:12 school:130...130...130... 至今没有看到九校的排名,如果九校排名正常的话,那yyhs的学生也太可怕了...估计要三百 ...
- [转] Spring MVC sample application for downloading files
http://www.codejava.net/frameworks/spring/spring-mvc-sample-application-for-downloading-files n this ...
- Handling events in an MVVM WPF application
Posted: June 30, 2013 | Filed under: MVVM, WPF, XAML |1 Comment In a WPF application that uses the ...
- js、PHP将分数字符串转换为小数
PHP:$s = "1/3"; $s = str_replace(array('[',']','mod'),array('(',')','%'),$s);//将原三字符串中的只有在 ...
- BZOJ 2038 小z的袜子 & 莫队算法(不就是个暴力么..)
题意: 给一段序列,询问一个区间,求出区间中.....woc! 贴原题! 作为一个生活散漫的人,小Z每天早上都要耗费很久从一堆五颜六色的袜子中找出一双来穿.终于有一天,小Z再也无法忍受这恼人的找袜子过 ...