标签:blog io os java 文件 div sp on c
public String readTxtFile(String filePath) { StringBuffer appInfolistInput = new StringBuffer(); try { String encoding = "UTF8"; File file = new File(filePath); if (file.isFile() && file.exists()) { InputStreamReader read = new InputStreamReader( new FileInputStream(file), encoding); BufferedReader bufferedReader = new BufferedReader(read); String lineTxt = null; while ((lineTxt = bufferedReader.readLine()) != null) { appInfolistInput.append(lineTxt); } read.close(); bufferedReader.close(); } else { System.out.println("找不到指定的文件"); } } catch (Exception e) { System.out.println("读取文件内容出错"); e.printStackTrace(); } return appInfolistInput.toString(); }
标签:blog io os java 文件 div sp on c
原文地址:http://www.cnblogs.com/zhangfei/p/3992191.html