zoukankan      html  css  js  c++  java
  • Properties获取属性

     1 import java.io.File;
     2 import java.io.FileInputStream;
     3 import java.io.IOException;
     4 import java.io.InputStream;
     5 import java.util.Properties;
     6 
     7 public class PropertiesUtil {
     8 
     9     private Properties appProperties = new Properties();
    10 
    11     /**
    12      * 加载文件路径
    13      */
    14     public void getAppProperties(String path) throws IOException {
    15         InputStream in = new FileInputStream( new File(path));
    16         appProperties.load(in);
    17         in.close();
    18     }
    19 
    20     /**
    21      * 获取属性
    22      * @param strFieldName - the field name
    23      * @return strPro the field content
    24      */
    25     public String getSpecialProperty(String strFieldName) throws IOException {
    26         String strProperty = strFieldName;
    27         String strPro = appProperties.getProperty(strProperty);
    28         return strPro != null ? strPro.trim() : strPro;
    29     }
    30 
    31 }
    Author:Pale Life
    From: 
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    js布尔型
    C#函数(十一)
    JavaScript+jQuery从小工到专家学习笔记数值
    C#函数(十)
    C#函数(九)
    jquery 操作复选框 下拉框
    jquery select操作大全
    Jquery与Json实现Ajax
    如何打造创业团队
    jquery select操作大全
  • 原文地址:https://www.cnblogs.com/live365wang/p/2732568.html
Copyright © 2011-2022 走看看