Java Properties和IO流结合
2021-03-05 14:29
标签:lang stat dwr read files store string stp exception Java Properties和IO流结合 标签:lang stat dwr read files store string stp exception 原文地址:https://www.cnblogs.com/flowliver/p/14320929.htmlpackage 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流结合
文章链接:http://soscw.com/index.php/essay/60488.html