시스템 프로퍼티란?
JVM이 시작할 때 자동 설정되는 시스템의 속성값
import java.util.Properties;
import java.util.Set;
public class GetPropertyExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
String osName = System.getProperty("os.name");
String userName = System.getProperty("user.name");
String userHome = System.getProperty("user.home");
System.out.println("운영체제이름: " + osName);
System.out.println("사용자 이름: " + userName);
System.out.println("사용자 홈디렉토리: " + userHome);
System.out.println("----------------------------");
System.out.println(" [ key ] value");
System.out.println("----------------------------");
//컬렉션에서 설명.
// JVM 구동시 자동설정된 속성정보목록.
Properties props = System.getProperties();
Set keys = props.keySet();
for(Object objKey : keys) {
String key = (String) objKey;
String value = System.getProperty(key);
System.out.println("[ " + key + " ]" + value);
}
}
}
'JAVA' 카테고리의 다른 글
String 클래스 문자열 비교(equals()) 예제 (0) | 2022.10.07 |
---|---|
String 문자추출(charAt()) 메소드 (0) | 2022.10.07 |
System 클래스 (currentTimeMillis,nano Time) (0) | 2022.10.07 |
Object 클래스 객체복제 clone() (0) | 2022.10.07 |
Object 클래스 객체 해시코드(hashCode()) (0) | 2022.10.07 |