속성 Hashtable 클래스의 하위 클래스이며 영구적인 속성 집합을 나타냅니다. 속성 스트림에 저장하거나 스트림에서 로드할 수 있습니다. 속성 목록의 각 키와 해당 값은 문자열입니다.
속성 파일을 Java에서 사용하여 구성을 외부화하고 키-값 쌍을 저장할 수 있습니다. . Properties.load() 메서드 속성 클래스는 .속성 을 로드하는 데 편리합니다. 키-값 형식의 파일 쌍 .
구문
public class Properties extends Hashtable
credentials.properties 파일

예
import java.io.*;
import java.util.*;
public class ReadPropertiesFileTest {
public static void main(String args[]) throws IOException {
Properties prop = readPropertiesFile("credentials.properties");
System.out.println("username: "+ prop.getProperty("username"));
System.out.println("password: "+ prop.getProperty("password"));
}
public static Properties readPropertiesFile(String fileName) throws IOException {
FileInputStream fis = null;
Properties prop = null;
try {
fis = new FileInputStream(fileName);
prop = new Properties();
prop.load(fis);
} catch(FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch(IOException ioe) {
ioe.printStackTrace();
} finally {
fis.close();
}
return prop;
}
} 출력
username: admin password: admin@123