zoukankan      html  css  js  c++  java
  • classloader example


    http://hi.baidu.com/bailang3106/blog/item/cd009ad4c9412908a18bb7bf.html

    package com.jd.cis.spider;

    import java.io.IOException;
    import java.io.InputStream;
    import java.net.URL;
    import java.util.Properties;

    public class Test {

        /**
         * @param args
         * @throws IOException
         */
        public static void main(String[] args) throws IOException {
            URL url1=Test.class.getClassLoader().getResource("conf/system.properties");
            URL url2=Thread.currentThread().getContextClassLoader().getResource("conf/system.properties");
            System.out.println(url1);
            System.out.println(url2);
           
            InputStream is1=Test.class.getClassLoader().getResourceAs

    Stream("conf/system.properties");
            InputStream is2=Thread.currentThread().getContextClassLoader().getResourceAsStream("conf/system.properties");
           
            Properties p1=new Properties();
            p1.load(is1);
           
            Properties p2=new Properties();
            p2.load(is2);
           
            System.out.println(p1.getProperty("service.url"));
            System.out.println(p2.getProperty("service.url"));
        }

    }


  • 相关阅读:
    monitor system
    monitor disk
    manage account
    windows
    backup daily
    shell 脚本编程概述
    OGNL表达式
    Struts2各个功能详解(2)-输入校验和拦截器
    struts2各个功能详解(1)----参数自动封装和类型自动转换
    Struts2源码解析2
  • 原文地址:https://www.cnblogs.com/lexus/p/2482533.html
Copyright © 2011-2022 走看看