网上看到许多对于Properties的读取查找,找了半天没有看到写的。肯能是太简单了,于是我查阅文档尝试了一下写的操作,记一下,才几行。
public class Read {
private static String path = "config.properties";
private static String other = "other.properties";
public static void main(String[] args) throws IOException {
//读
InputStream in = new BufferedInputStream(new FileInputStream(path));
Properties prop = new Properties();
prop.load(in);
System.out.println(prop.getProperty("one"));
//写
OutputStream out = new FileOutputStream(new File(other));
prop.store(out, "");
out.close();
in.close();
}
}
读写都在这里了