java Properties를 이용하여 config파일 읽기


java Properties를 이용하여 config파일 읽기

1. 클래스 선언 import java.util.*; import java.io.FileInputStream; import java.io.InputStream; public class Config() { public Config() { configFile = new java.util.Properties(); try { // 방법 1 시작 (이 방법은 프로젝트 내부의 파일만 사용할 수 있다.) configFile.load(this.getClass().getClassLoader().getResourceAsStream("config.conf")); // 방법 1 끝 // 방법 2 시작 InputStream in = new FileInputStream("config.conf"); configFile.load(in); in.close(); // 방법 2 끝 } catch(Exception e) { e.printStackTrace(); } } public String getProperty(St...


#IT·컴퓨터

원문링크 : java Properties를 이용하여 config파일 읽기