1. 程式人生 > >eclipse中讀取json配置檔案,相對路徑不能以斜槓打頭。

eclipse中讀取json配置檔案,相對路徑不能以斜槓打頭。

fileReader = new FileReader("src/json_for_test/netDiagnoseConfigParameter"); BufferedReader bufferedReader = new BufferedReader(fileReader); StringBuffer stringBuffer = new StringBuffer(); String temp = null; try { while((temp = bufferedReader.readLine()) != null){ stringBuffer.append(temp); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } diagnoseConfig = new JSONObject(stringBuffer.toString());