从文本文件中读取内容

读取内容存为String

public static String parseJSONFile(String filename) throws JSONException, IOException {
   String content = new String(Files.readAllBytes(Paths.get(filename)))
   return content
}

读取内容存为JSONObject

public static JSONObject parseJSONFile2(String filename) throws JSONException, IOException {
   String content = new String(Files.readAllBytes(Paths.get(filename)))
   return new JSONObject(content)
}

  

猜你喜欢

转载自www.cnblogs.com/MasterMonkInTemple/p/10442496.html