PropertiesUtil.java

package utils;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties; public class PropertiesUtil {
private static InputStream in;//=prop.class.getClassLoader().getResourceAsStream("resource/date.properties");
private static Properties props;
private static String filePath=PropertiesUtil.class.getClassLoader().getResource("resource/date.properties").getFile();//.getPath();
static{
props=new Properties(); try {
in=new BufferedInputStream(new FileInputStream(filePath));
props.load(in);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
public static String readStringValue(String key) {
return props.getProperty(key);
} public static int readIntValue(String key) {
return Integer.valueOf(props.getProperty(key));
} public static Float readFloatValue(String key) {
return Float.valueOf(props.getProperty(key));
} public static String[] readStringArray(String key,String regex) {
return props.getProperty(key).split(regex);
} /**
* @param args
*/
public static void main(String[] args) {
System.out.println(PropertiesUtil.readStringValue("aa"));
System.out.println(PropertiesUtil.readIntValue("age"));
System.out.println(PropertiesUtil.readFloatValue("fl"));
System.out.println(PropertiesUtil.readStringArray("aa",",")[1]);
} }

date.properties

#用来测试的
aa=1,2,3,4,54,54,5,43,5,32,3,4532,45
age=1
fl=1.1

public static boolean isNumeric(String str){
        Pattern pattern = Pattern.compile("[0-9]*");
        return pattern.matcher(str).matches();   
     }

String.format("%03d",Integer.valueOf(no2)+1);

读propert文件的更多相关文章

  1. outlook——还原“未读邮件”文件夹

    参考链接:http://office.microsoft.com/zh-cn/outlook-help/HA010283248.aspx 摘抄: 还原“未读邮件”文件夹 全部显示 全部隐藏 “未读邮件 ...

  2. matlab文件操作及读txt文件(fopen,fseek,fread,fclose)

    文件操作是一种重要的输入输出方式,即从数据文件读取数据或将结果写入数据文件.MATLAB提供了一系列低层输入输出函数,专门用于文件操作. 1.文件的打开与关闭 1)打开文件 在读写文件之前,必须先用f ...

  3. MATLAB文件操作及读txt文件

    转自:http://blog.csdn.net/vblittleboy/article/details/8049748 文件操作是一种重要的输入输出方式,即从数据文件读取数据或将结果写入数据文件.MA ...

  4. read(),write() 读/写文件

    read read()是一个系统调用函数.用来从一个文件中,读取指定长度的数据到 buf 中. 使用read()时需要包含的头文件: <unistd.h> 函数原型: ssize_t re ...

  5. LinqToXML~读XML文件

    linq的出现,带给我们的是简结,快速,可读性,它由linq to sql,linq to object,linq to XML组成,我的博客之前有对linq to sql的讲解,而今天,我将讲一个l ...

  6. python中判断readline读到文件末尾

    fp = open('somefile.txt') while True: line = fp.readline() if not line: #等价于if line == "": ...

  7. C#、C++用GDAL读shp文件(转载)

    C#.C++用GDAL读shp文件 C#用GDAL读shp文件 (2012-08-14 17:09:45) 标签: 杂谈 分类: c#方面的总结 1.目前使用开发环境为VS2008+GDAL1.81 ...

  8. NOPI读xls文件写到txt中(NPOI系列二)

    private void button2_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); //找 ...

  9. 用python3读CSV文件,出现UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 0: invalid con

    使用pd.read_csv()读csv文件时,出现如下错误: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd0 in position ...

随机推荐

  1. Color a Tree[HDU1055]

    Color a Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  2. Struts2_ValueStack,OGNL详解

    一.ValueStack    1.ValueStack是一个接口,在struts2中使用OGNL(Object-Graph Navigation Language)表达式实际上是使用实现了Value ...

  3. CSS光标属性一览表

    光标类型 CSS 把你的光标放到相应文字上查看效果 要注意光标的实际效果依赖于用户的系统设置,与你在这里看到的效果并不一定一致. 十字准心 cursor: crosshair; 手 cursor: p ...

  4. 给NSString增加Java风格的方法

    给NSString增加Java风格的方法 文章目录 我实在受不了 NSString 冗长的方法调用了,每次写之前都要查文档.特别是那个去掉前后多余的空格的方法,长得离谱.与之对应的别的语言,拿 jav ...

  5. Add Customerlize Button in More Button List In Odoo

    There're two commen type of actions in odoo: ir.actions.server,ir.actions.client_multi 1.Using ir.ac ...

  6. 免杀ASP一句话

    <% wei="日日日)""wei""(tseuqer lave 日" execute(UnEncode(wei)) function ...

  7. 如何处理NBU Frozen Media

    https://support.symantec.com/en_US/article.TECH21473.html

  8. 连连看的设计与实现——四人小组项目(GUI)

    项目GUI界面经过简单设计,整理如下:(图片截取致宠物连连看3.1) 点开游戏后界面显示: 点击菜单游戏—>初级 后显示 -------------------------- > 当游戏时 ...

  9. OpenCV学习笔记——滑动条开关

    由于opencv库中并没有专门为开关而设的函数,可以用滑动条做开关 代码: #include<highgui.h> #include<cv.h> int g_switch_va ...

  10. FZU 1025 状压dp 摆砖块

    云峰菌曾经提到过的黄老师过去讲课时的摆砖块 那时百度了一下题目 想了想并没有想好怎么dp 就扔了 这两天想补动态规划知识 就去FZU做专题 然后又碰到了 就认真的想并且去做了 dp思想都在代码注释里 ...