public static void main(String[] args) throws IOException { String filePath = "E:\\data\\popo\\yanhua.log"; FileInputStream fin = new FileInputStream(filePath); InputStreamReader reader = new InputStreamReader(fin); BufferedReader buffReader = new BufferedReader(reader); String strTmp; while ((strTmp = buffReader.readLine()) != null) { System.out.println(strTmp); } buffReader.close(); } public static void writeFile(String filePath, String content) throws IOException { //true表示追加内容 BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filePath, true)); bufferedWriter.write(content); //换行 bufferedWriter.newLine(); bufferedWriter.close(); System.out.println("写入文件成功"); }
标签:文件,String,filePath,读写,strTmp,bufferedWriter,buffReader,new From: https://www.cnblogs.com/wencong/p/16871795.html