码迷,mamicode.com
首页 > 编程语言 > 详细

java读写properties文件

时间:2016-12-01 23:07:58      阅读:181      评论:0      收藏:0      [点我收藏+]

标签: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文件

标签:java读写properties文件

原文地址:http://matengbing.blog.51cto.com/11395502/1878508

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!