首页 > 代码库 > 从属性文件中读取内容

从属性文件中读取内容

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"));
    }
}

从属性文件中读取内容