java 读取Properties

package com.test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import  java.util.*;
public class PropertiesTest {

public  static  void  main(String []args) throws FileNotFoundException ,IOException {
    Properties pro = new Properties();
    System.out.println(System.getProperty("user.dir"));
    FileInputStream in = new FileInputStream("D:\\Q\\mytest\\TestJdk\\src\\main\\resources\\a.properties");
    pro.load(in);
    in.close();

    System.out.println(pro.getProperty("userName"));

}


}

 

a.properties

userName=123
pwd=aaaa
posted @ 2018-01-12 13:53  甜菜波波  阅读(164)  评论(0编辑  收藏  举报