讀取配置及文件路徑

前文:

             

一、讀取配置文件方式

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標準,所以網絡路徑用“/”。

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