public class demo05 { public static void main(String[] args) throws IOException { Properties prop = new Properties(); prop.setProperty("tt","20"); prop.setProperty("yy","20"); prop.setProperty("aa","20"); prop.store(new FileWriter("D:\\aaaaa.txt"),"ttt"); prop.load(new FileReader("D:\\aaaaa.txt")); Set<String> set = prop.stringPropertyNames(); for (String key : set) { String value = prop.getProperty(key); System.out.println(key+"-"+value); } } }