標籤:java讀寫properties檔案
package tst.socket.properties;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.util.Properties;public class TestProperties { public static void main(String[] args) throws Exception { new TestProperties().testProperties(); } public void testProperties() throws IOException{ Properties properties=new Properties(); InputStream ips1 = this.getClass().getClassLoader().getResourceAsStream("tst/socket/properties/info.properties"); properties.load(ips1); String count=properties.getProperty("線程"); System.out.println(count); File file=new File("test.info.properties"); if(!file.exists()){ file.createNewFile(); } properties.store(new FileOutputStream(file), "注釋"); }}
本文出自 “matengbing” 部落格,請務必保留此出處http://matengbing.blog.51cto.com/11395502/1878508
java讀寫properties檔案