사용자 도구

사이트 도구


java:classpathresource

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
마지막 판 양쪽 다음 판
java:classpathresource [2019/11/22 13:28]
kwon37xi
java:classpathresource [2019/11/22 13:31]
kwon37xi [Pure Java]
줄 1: 줄 1:
-====== Java Classpath Resources ======+====== Java Classpath Resource ======
   * [[http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html|Smartly load your properties - JavaWorld]] 이 문서 정리   * [[http://www.javaworld.com/javaworld/javaqa/2003-08/01-qa-0808-property.html|Smartly load your properties - JavaWorld]] 이 문서 정리
   * [[https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html|Accessing Resources]]   * [[https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html|Accessing Resources]]
 +  * [[https://www.mkyong.com/java/java-read-a-file-from-resources-folder/|Java – Read a file from resources folder – Mkyong.com]]
  
 ===== Pure Java ===== ===== Pure Java =====
줄 8: 줄 9:
 Class.getResourceAsStream ("/some/pkg/resource.properties"); // "/"가 없으면 상대경로 Class.getResourceAsStream ("/some/pkg/resource.properties"); // "/"가 없으면 상대경로
 ResourceBundle.getBundle ("some.pkg.resource"); ResourceBundle.getBundle ("some.pkg.resource");
 +
 +// 파일로 확보. jar로 묶여있을 경우 작동안함.
 +File file = new File(getClass().getClassLoader().getResource("database.properties").getFile());
 </code> </code>
  
java/classpathresource.txt · 마지막으로 수정됨: 2019/11/22 13:32 저자 kwon37xi