java读取txt文件源码如下,仅是最简略版本:
package p1; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class readTXT { public static void main(String[] args) throws IOException { String filePath = "F:\\TxtTest.txt"; FileInputStream fis = new FileInputStream(filePath); InputStreamReader isr = new InputStreamReader(fis); BufferedReader br = new BufferedReader(isr); String line; for (;(line=br.readLine())!=null;) { System.out.println(line); } br.close(); isr.close(); fis.close(); } }
时间: 2024-11-05 12:17:15