Notice
Recent Posts
Recent Comments
반응형
오늘도 공부
properties to hashmap 본문
반응형
package org.kodejava.example.util;
import java.util.Properties;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
public class PropertiesToMap {
public static void main(String[] args) {
//
// Create a new instance of Properties.
//
Properties properties = new Properties();
//
// Populate properties with a dummy application information
//
properties.setProperty("app.name", "HTML Designer");
properties.setProperty("app.version", "1.0");
properties.setProperty("app.vendor", "HTML Designer Inc");
//
// Create a new HashMap and pass an instance of Properties. Properties
// is an implementation of a Map which keys and values stored as in a
// string.
//
Map<String, String> map = new HashMap<String, String>((Map) properties);
//
// Get the entry set of the Map and print it out.
//
Set propertySet = map.entrySet();
for (Object o : propertySet) {
Map.Entry entry = (Map.Entry) o;
System.out.printf("%s = %s%n", entry.getKey(), entry.getValue());
}
}
}반응형
'자바 > 자바팁' 카테고리의 다른 글
| [펌]Transfer a file via Socket (0) | 2011.10.20 |
|---|---|
| [자바]소켓(CLient측) 연결 확인 (1) | 2011.10.20 |
| 네이버 svn 설치방법 참고 (0) | 2010.12.09 |
| 네이버 svn 설치방법 (0) | 2010.12.08 |
| [펌]자바 IO 대충 정리..(필요할때 쓰자) (0) | 2010.12.03 |
