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