준준의 기록일지

[Java] resourcebundle 클래스 경로가 아닌 파일경로에서 가져오기. 본문

카테고리 없음

[Java] resourcebundle 클래스 경로가 아닌 파일경로에서 가져오기.

junjunwon 2021. 3. 9. 18:09

"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."




private static ResourceBundle fromClassLoader(String dir, String bundleName) throws MalformedURLException {

        File file = new File(dir);

        URL[] urls = {file.toURI().toURL()};

        ClassLoader loader = new URLClassLoader(urls);

        // Properties file name = test.properties. The .properties extension is appended to bundle name

        return ResourceBundle.getBundle(bundleName, Locale.getDefault(), loader);

    }

 

 

 

gist.github.com/mobleyc/73f1a0036d9ef3fdc7ab

 

Loading resource bundles in Java from property files outside of classpath, with different file extensions.

Loading resource bundles in Java from property files outside of classpath, with different file extensions. - app.java

gist.github.com