java|java -jar ***.jar 运行可执行配置文件方法

private static Properties loadPropertiesFile(String fullFile) { String webRootPath = null; if (null == fullFile || fullFile.equals("")) { throw new IllegalArgumentException("Properties file path can not be null" + fullFile); } //webRootPath = DBPoolConnection.class.getClassLoader().getResource("").getPath(); //webRootPath = new File(webRootPath).getParent(); //webRootPath = new File(webRootPath).getParent(); InputStream inputStream = null; Properties p = null; //System.getProperty("user.dir") try { //inputStream = DBPoolConnection.class.getClassLoader().getResourceAsStream(fullFile); //String filePath = System.getProperty("user.dir") + "/conf/"+fullFile; //inputStream = new BufferedInputStream(new FileInputStream(filePath)); inputStream= ClassLoader.getSystemClassLoader().getResourceAsStream(fullFile); //inputStream = new FileInputStream(new File( System.getProperty("user.dir") + File.separator + fullFile)); p = new Properties(); p.load(inputStream); } catch (Exception e) { e.printStackTrace(); } finally { try { if (null != inputStream) { inputStream.close(); } } catch (Exception e) { e.printStackTrace(); } }return p; }

    推荐阅读