Java各种文件的读写和文件夹遍历方法
读取文本文件 import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.HashMap; public class TxtFileRead { public static void main(String[] args) { readFile1(); System.out.println("==================="); //readFile2(); //JDK 7及以上才可以使用 } public static void readFile1() { FileInputStream fis = null; InputStreamReader isr = null; BufferedReader br = null; try { fis = new FileInputStream("c:/temp/abc.txt"); // 节点类 isr = new InputStreamReader(fis, "UTF-8");