기본 콘텐츠로 건너뛰기

5월, 2015의 게시물 표시

Android, Properties, data to file simple src

public static void saveProperty(String key, String value){ Properties properties = new Properties(); String file = ... try { if ( new File(file).exists()){ properties.load( new FileInputStream(file)); } properties.put(key, value); properties.store( new FileOutputStream(file), null ); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static String loadProperty(String key){ Properties properties = new Properties(); String file = ... try { properties.load( new FileInputStream(file)); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return (String)properties.get(key); }