从文本文件中读取内容

读取内容存为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)
}

  

posted on 2019-02-27 11:21  张缤分  阅读(171)  评论(0)    收藏  举报

导航