zoukankan      html  css  js  c++  java
  • java 常用工具整理

    mapUtil map操作工具类

    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-collections4</artifactId>
                <version>4.2</version>
            </dependency>
    

    获取配置文件工具类

    public class PropertiesUtil {
    
    	private static final String PATH = "conf.properties";
    
        public static String getValue(String key){
            Properties pps = new Properties();
            InputStream in = null;
            try {
    //            in = new BufferedInputStream (new FileInputStream(PATH));
                in = Thread.currentThread().getContextClassLoader().getResourceAsStream(PATH);
                pps.load(in);
                String value = pps.getProperty(key);
                return value;
            }catch (IOException e) {
                e.printStackTrace();
                return null;
            }finally {
            	try{
            		if(in != null){
    			        in.close();
    		        }
            	}catch (IOException e) {
            		e.printStackTrace();
    			}
    		}
        }
    
        public static Integer getIntValue(String key){
    	    String value = getValue(key);
    	    return Integer.parseInt(value);
        }
    
    }
    
  • 相关阅读:
    leetcode 414
    Leetcode 495
    Leetcode 485题
    Python 24点(2)
    python 24点
    我的第一次作业
    Django
    multiprocessing模块
    遍历文档树
    shutil模块
  • 原文地址:https://www.cnblogs.com/zhucww/p/10250287.html
Copyright © 2011-2022 走看看