public static void main(String[] args) { saveProperties("aa","bb"); } public static void saveProperties(String key,String value){ Properties p = new Properties(); p.setProperty(key, value); try { FileOutputStream out = new FileOutputStream("d:\mess.properties"); p.store(out, "test"); out.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }