java 写 Properties文件



java 写 Properties文件网上看到许多对于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();
	}

}

读写都在这里了



java 写 Properties文件,布布扣,bubuko.com

java 写 Properties文件

上一篇:用python把数字转换成字母


下一篇:c++异常Try catch