package Iodemo; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Properties; import java.util.Set; public class PropertiesDemo { public static void main(String[] args) throws IOException { writes(); reads(); } private static void reads() throws IOException { FileReader fileReader = new FileReader("1.txt"); Properties pp = new Properties(); pp.load(fileReader); fileReader.close(); System.out.println(pp); } private static void writes() throws IOException { Properties pp = new Properties(); pp.setProperty("aaa","111"); pp.setProperty("bbb","222"); FileWriter f = new FileWriter("1.txt"); pp.store(f,null); f.close(); } }