文件操作! Java
程序员文章站
2022-07-15 10:29:45
...
//读文件转成字符串! public static String fileToString(String fileName) throws IOException { String lineContent = null;// StringBuffer str = new StringBuffer(); FileReader fr; try { fr = new FileReader(fileName); BufferedReader br = new BufferedReader(fr);// lineContent = new String(); lineContent = br.readLine().trim(); do { str.append(lineContent.trim()); } while ((lineContent = br.readLine()) != null); } catch (Exception e) { e.printStackTrace(); } return str.toString(); }
下一篇: 聊天机器人:转载:当前顶尖的聊天机器人