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

Java Properties和IO流结合

时间:2021-01-26 11:55:56      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:lang   stat   dwr   read   files   store   string   stp   exception   

package com.company;

import java.io.*;
import java.util.Properties;

public class Main {
    public static void main(String[] args) throws IOException {
       myWrite();
       myReader();
    }

    private static void myReader() throws IOException {
        final Properties properties = new Properties();
        final BufferedReader bufferedReader = new BufferedReader(new FileReader("E:\\files\\codesrc\\IDEA\\FirstPrj\\src\\com\\io\\滕王阁序.txt"));
        properties.load(bufferedReader);
        System.out.println(properties);
        bufferedReader.close();


    }

    private static void myWrite() throws IOException{
        final Properties properties = new Properties();
        properties.setProperty("张san","23");
        properties.setProperty("陈2","23");
        properties.setProperty("韩6","23");
        final BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("E:\\files\\codesrc\\IDEA\\FirstPrj\\src\\com\\io\\滕王阁序.txt"));
        properties.store(bufferedWriter,"First Commit");
        bufferedWriter.close();

    }
}



Java Properties和IO流结合

标签:lang   stat   dwr   read   files   store   string   stp   exception   

原文地址:https://www.cnblogs.com/flowliver/p/14320929.html

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