public static ArrayListreadTxtFile() { String fileName = JavaFile.class.getClassLoader().getResource("filename/list.txt").getPath(); ArrayList arrayList = new ArrayList<>(); try { File jsonFile = new File(fileName); FileReader fileReader = new FileReader(jsonFile); //Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8"); BufferedReader bf = new BufferedReader(fileReader); int ch = 0; StringBuffer sb = new StringBuffer(); String str; while ((str = bf.readLine()) != null) { arrayList.add(str); } fileReader.close(); bf.close(); } catch (IOException e) { e.printStackTrace(); return null; } return arrayList; } // 读取json文件 public static String readJsonFile(String fileName) { String jsonStr = ""; try { File jsonFile = new File(fileName); FileReader fileReader = new FileReader(jsonFile); Reader reader = new InputStreamReader(new FileInputStream(jsonFile), "utf-8"); int ch = 0; StringBuffer sb = new StringBuffer(); while ((ch = reader.read()) != -1) { sb.append((char) ch); } fileReader.close(); reader.close(); jsonStr = sb.toString(); return jsonStr; } catch (IOException e) { e.printStackTrace(); return null; } } import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.ouyanglol.neo4j.vo.EventMessage; public static List
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)