Thursday, May 6, 2010

Java에서 파일 불러올때 ClassPath로 불러오기



My Software Recipes: Java - Property file from classpath
he Problem:
 wanted to read a property file from the classpath.
he Solution:
 property file called test.properties in the classpath.
URL url =  ClassLoader.getSystemResource("test.properties");
Properties p = new Properties();
p.load(new FileInputStream(new File(url.getFile())));

System.out.println(p.getProperty("my.property"));

주사위 놀이

Busan city, South Korea
All about programming knowledge such as Java, Flex and Oracle DB Management.

Followers