从属性文件加载属性
import java.io.File; import java.io.IOException;// 来 自 N o w J a v a . c o m - 时 代 Java import java.io.InputStream; import java.nio.file.FileSystems; import java.nio.file.Files; import java.util.Properties; public class Main { public static void main(String[] args) throws Exception { Properties props = new Properties(); try (InputStream in = Files.newInputStream(FileSystems.getDefault() .getPath( System.getProperty("user.dir") + File.separator + "db_props.properties"));) { props.load(in); /** from 时代Java - N o w J a v a . c o m**/ in.close(); } catch (IOException ex) { ex.printStackTrace(); }