记录错误,打开文件流一定要关闭并重新打开文件流,不然取的文件内容永远是第一次取的文件内容:
1 /** 2 * 读取配置文件 3 */ 4 private Properties readProperties() { 5 Properties properties = new Properties(); 6 try { 7 InputStream inputStream = new FileInputStream(filePath); 8 BufferedInputStream in = new BufferedInputStream(inputStream); 9 properties.load(in); 10 inputStream.close(); 11 in.close(); //关闭文件流 12 } catch (IOException e) { 13 e.printStackTrace(); 14 } 15 return properties; 16 }