从属性文件中读取内容

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class PropertiesDemo03 {
    public static void main(String[] args) {
        Properties pro = new Properties();
        File file = new File("E:" + File.separator + "Area.properties");
        try {
            pro.load(new FileInputStream(file));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("BJ:" + pro.getProperty("BJ"));
    }
}

原文地址:https://www.cnblogs.com/vonk/p/3961335.html