前文:
一、讀取配置文件方式
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標準,所以網絡路徑用“/”。