Properties props = new Properties(); String url = this.getClass().getClassLoader().getResource( "config.properties").toString().substring(6); String empUrl = url.replace("%20", " ");// 如果你的文件路径中包含空格,是必定会报错的 System.out.println(empUrl); InputStream in = null; try { in = new BufferedInputStream(new FileInputStream(empUrl)); props.load(in); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); }