Java.util.Properties.load(InputStream inStream) 方法 Java.util.Properties.list(PrintWriter out) 方法 Java.util.Properties.load(Reader reader) 方法 Java.util.Properties.load(InputStream inStream) 方法 package com.codingdict; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.*; public class PropertiesDemo { public static void main(String[] args) { Properties prop = new Properties(); String s = "Height=200"; String s2 = "Width=15"; try { // create a new input and output stream FileOutputStream fos = new FileOutputStream("properties.txt"); FileInputStream fis = new FileInputStream("properties.txt"); // write the first property in the output stream file fos.write(s.getBytes()); // change the line between the two properties fos.write("\n".getBytes()); // write next property fos.write(s2.getBytes()); // load from input stream prop.load(fis); // print the properties list from System.out prop.list(System.out); } catch (IOException ex) { ex.printStackTrace(); } } } Java.util.Properties.list(PrintWriter out) 方法 Java.util.Properties.load(Reader reader) 方法