DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Jean-pierre has posted 6 posts at DZone. View Full User Profile

Loading A Property File From The Classpath

  • submit to reddit
        Loads a property file located anywhere in the classpath

    private Properties getPropertiesFromClasspath(String propFileName) throws IOException {
        // loading from the classpath
        Properties props = new Properties();
        InputStream inputStream = this.getClass().getClassLoader()

        if (inputStream == null) {
            throw new FileNotFoundException("property file '" + propFileName
                + "' not found in the classpath");


        return props;