java读properties的通用类,兼容linux和windows
package util; import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* 获取配置文件信息
*
* @author Carl
*
*/
public final class GetProperties {
private static Properties prop = null;
static{
prop = new Properties();
//设置properties文件路径,以src为根路径(config.properties 处于src根目录下)
InputStream in = GetProperties.class.getResourceAsStream("/config.properties");
try {
prop.load(in);
} catch (IOException e) {
System.out.println("读取配置文件失败---->>>>----(/src/config.properties)");//会失败!!!!
e.printStackTrace();
}
} /**
* 根据传入的KEY获取配置文件中对应的值
* @param key
* @return
*/
public static String getPropertieValue(String key){
String value = "";
value = prop.getProperty(key).trim();
return value;
}
} http://nannan408.iteye.com/blog/2022532
java读properties的通用类,兼容linux和windows的更多相关文章
- Java读properties文件中文乱码问题的解决方法
java读properties文件,包含中文字符的主要有两种: 1.key中包含中文字符的(value中也有可能包含) 2.key中不包含中文字符的(value中有可能包含) 1.key中包含中文字符 ...
- java读properties文件 乱码
java读properties文件,包含中文字符的主要有两种: 1.key中包含中文字符的(value中也有可能包含) 2.key中不包含中文字符的(value中有可能包含) 1.key中包含中文字符 ...
- Java 读Properties
import java.io.*; import java.util.Properties; public class Study { public static void main(String[] ...
- Java读取properties文件工具类并解决控制台中文乱码
1.建立properts文件(error.message.properties) HTTP201= 请求成功并且服务器创建了新的资源 2.在spring-mvc.xml文件(applicationCo ...
- Java读取properties配置文件工具类
1. PropertyUtils.java package javax.utils; import java.io.InputStream; import java.util.Properties ...
- java读取properties的工具类PropertiesUtil
package org.properties.util; import java.io.FileInputStream; import java.io.FileOutputStream; import ...
- java获取本机器的IP(linux和windows)
目录 描述 方案描述 获取Windows下的IP 获取linux下的IP 判断操作系统的类型 最后将上面三个方法进行整合 参考 描述 由于项目是部署在集群上的,需要项目能够自动采集各机器的信息.jav ...
- 个人项目-WC(C/C++ 兼容Linux和Windows)
一.Github地址 https://github.com/S-TRAVELER/WC 实现的功能: 支持 -c 支持 -w 支持 -l 支持 -s 支持 -a 图形界面 多参数(文件名或通配符表达式 ...
- phantomjs的使用+Java代码+依赖js(兼容Linux和windows版本)
1. 在使用phantomjs的时候需要下载phantomjs,网上有window版本和Linux版本.将phantomjs放在Linux上的指定位置之后(如下面的/home/tpl/phantom ...
随机推荐
- Solr4.3之拼写检查Spellcheck功能
原文地址:http://www.656463.com/article/iaquii.htm 拼写检查功能,能在搜索时提供一个较好用户体验,所以,主流的搜索引擎都有这个功能,在这之前,笔者先简单的说一下 ...
- 利用快速排序原理找出数组中前n大的数
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #define MAX_SIZE 400001 ...
- 在sublime中使用less
高亮显示: 可以在Less文件中显示语法高亮,这样看起来会更舒服一些. 按下Ctrl+Shift+P调出命令面板:输入install调出Install Package选项并回车:输入less,选中并安 ...
- [LeetCode]题解(python):111 Minimum Depth of Binary Tree
题目来源 https://leetcode.com/problems/minimum-depth-of-binary-tree/ Given a binary tree, find its minim ...
- Android笔记-获取图片
1. 图片放在sdcard中,根据路径获得: Bitmap imageBitmap = BitmapFactory.decodeFile(path) (path 是图片的路径,跟目录是/sdcard ...
- LeetCode -- Triangle 路径求最小和( 动态规划问题)
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...
- urlencode和rawurlencode的区别
摘自http://blog.csdn.net/doggie1024/article/details/5698615 urlencode:返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将 ...
- js获取网站根目录
//js获取网站根路径(站点及虚拟目录),获得网站的根目录或虚拟目录的根地址 function getRootPath(){ var strFullPath=window ...
- 目标检测的图像特征提取之(一)HOG特征
http://blog.csdn.net/liulina603/article/details/8291093
- Java程序员面试失败的5大原因
下面是Java程序员面试失败最有可能的5大原因,当然也许这5点原因适用于所有的程序员,所以,如果你是程序员,请认真阅读以下内容. #1 说得太少 尤其是那些开放式的问题,如“请介绍下你自己”或“请讲一 ...