Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Properties; public class Main { public static List<String> getPropertyList(String filePath, String fileName, String propertyName, String defaultValue) { try { Properties p = loadPropertyInstance(filePath, fileName); String v = p.getProperty(propertyName, defaultValue); String[] iA = v.split("(?<!\\\\);"); for (int i = 0; i < iA.length; i++) { iA[i] = iA[i].replaceAll("(\\\\)+$", "").replaceAll("\\\\;", ";").replaceAll("\\\\\\\\", "\\\\"); } return Arrays.asList(iA); } catch (Exception e) { e.printStackTrace(); return null; } } public static Properties loadPropertyInstance(String filePath, String fileName) { try { File d = new File(filePath); if (!d.exists()) { d.mkdirs(); } File f = new File(d, fileName); if (!f.exists()) { f.createNewFile(); } Properties p = new Properties(); InputStream is = new FileInputStream(f); p.load(is); is.close(); return p; } catch (Exception e) { e.printStackTrace(); return null; } } public static String getProperty(String filePath, String fileName, String propertyName) { try { Properties p = loadPropertyInstance(filePath, fileName); return p.getProperty(propertyName); } catch (Exception e) { e.printStackTrace(); return null; } } public static String getProperty(String filePath, String fileName, String propertyName, String defaultValue) { try { Properties p = loadPropertyInstance(filePath, fileName); return p.getProperty(propertyName, defaultValue); } catch (Exception e) { e.printStackTrace(); return null; } } public static boolean getProperty(String filePath, String fileName, Map<String, String> propertyMap) { try { Properties p = loadPropertyInstance(filePath, fileName); for (String name : propertyMap.keySet()) { propertyMap.put(name, p.getProperty(name, propertyMap.get(name))); } return true; } catch (Exception e) { e.printStackTrace(); return false; } } }