public static class read { public static String txt2String(File file){ StringBuilder result = new StringBuilder(); try{ BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件 String s = null; while((s = br.readLine())!=null){//使用readLine方法,一次读一行 result.append(System.lineSeparator()+s); } br.close(); }catch(Exception e){ e.printStackTrace(); } return result.toString(); } public static void main(String[] args) { String txt2String = txt2String(new File("C:\\Users\\xiang\\Desktop\\20220902.txt")); JSONObject jsonObject = JSONArray.parseObject(txt2String); JSONArray jsonArray; jsonArray = jsonObject.getJSONArray("result"); System.out.println(jsonArray); }