一、读取properties文件:

properties中的内容:

server.ip = 127.0.0.1
server.port = 22
//原生java即可读取
public static void setting() throws FileNotFoundException, IOException{
File configFile = new File("conf/parameters.properties");
FileInputStream fis = new FileInputStream(new File(configFile
.getAbsoluteFile().getCanonicalPath()));
Properties props = new Properties();
props.load(fis);
String serverIp = (String) props.get("server.ip");
InetAddress inetAddress = InetAddress.getByName(serverIp);
Integer serverPort = Integer.valueOf((String) props.get("server.port"));
}

二、读取ini文件:

ini文件中的内容:

[server]
ip=127.0.0.1
port=22

需要引入ini4j的jar包,包下载地址:https://repo1.maven.org/maven2/org/ini4j/ini4j/0.5.4/ini4j-0.5.4.jar

Wini ini = new Wini(new File("conf/monitor.ini"));
String serverIp = ini.get("server","ip");
InetAddress inetAddress = InetAddress.getByName(serverIp);
Integer serverPort = Integer.valueOf(ini.get("server","port"));

最新文章

  1. 快速Android开发系列网络篇之Volley
  2. laravel框架中容器类简化代码-摘自某书
  3. 背水一战 Windows 10 (30) - 控件(文本类): AutoSuggestBox
  4. 47个过程(PMBOK2008)
  5. IIS的配置
  6. September 9th 2016 Week 37th Friday
  7. ibatis动态查询条件
  8. <转>thinkphp的各种内部函数 D()、F()、S()、C()、L()、A()、I()详解
  9. 【Redis】配置redis主从复制
  10. 关于Java(标识符规则)
  11. 2014第35周三jquery最近用到的内容总结
  12. IOS_多线程_ASI_AFN_UIWebView
  13. 学习笔记TF009:对数几率回归
  14. 练习html,css,js仿制百度首页
  15. Axure RP 7 8
  16. python之路(五)-文件操作
  17. spark、standalone集群 (2)集群zookeeper 热备
  18. HDU6031 Innumerable Ancestors 倍增 - 题意详细概括 - 算法详解
  19. 【Oracle】【8】大批量update某个字段
  20. Windows 下vim的配置文件_vimrc

热门文章

  1. 【用户体验度量】用户费力度评分(CES)
  2. (十)java虚拟机性能监控工具
  3. Nginx作为负载均衡把客户端真实IP发送给后端配置
  4. Spring Aop(十六)——编程式的自定义Advisor
  5. CEIWEI USBMonitor监控驱动 OCX/SDK USB 监控精灵 USB过滤驱动
  6. Egret入门学习日记 --- 第三篇 (书中 3.4 内容)
  7. COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8'
  8. Linux程序Segmentation fault (core dumped)
  9. [翻译向] 当flush privileges生效时
  10. oracle学习笔记day1