import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public class Test { public static void main(String[] args) throws IOException { Test t =new Test(); t.a(); } public void a() throws IOException{ ClassLoader classLoader = getClass().getClassLoader(); String configFilePath = classLoader.getResource("config.properties").getFile(); FileInputStream is = null; Properties dbproperties = new Properties(); is = new FileInputStream(configFilePath); dbproperties.load(is); String db_url = dbproperties.getProperty("db_url").toString(); System.out.println(db_url); } }