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"));
}
}