读取配置及文件路径

前文:

             

一、读取配置文件方式

1.读取项目内部配置文件

    val in: InputStream = this.getClass.getClassLoader.getResourceAsStream("InJar.properties")
    val properties = new Properties()
    properties.load(in)

2.读取项目外部(系统下)配置文件

    val in = new BufferedInputStream(new FileInputStream("\\D:\\Tmp\\OutJar.properties"))
    val properties = new Properties()
    properties.load(in)

二、Windows和Linux路径区别

  Windows:

    “/”是表示参数,“\”是表示本地路径。

  Linux和Unix:

    “/”表示路径,“\”表示转义,“-”和“--”表示参数。

  网络:

    由于网络使用Unix标准,所以网络路径用“/”。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章