Java逐行读取数据

逆水行舟用力撑,一篙松劲退千寻。这篇文章主要讲述Java逐行读取数据相关的知识,希望能为你提供帮助。

import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; public class ClassInfoSort { static String str = null; public static void main(String[] args) { read(); } public static void read() { File file = new File("test.txt"); FileInputStream fin = null; BufferedReader bfr = null; try { fin = new FileInputStream(file); bfr = new BufferedReader(new InputStreamReader(fin)); String str = null; while((str=bfr.readLine()) != null) { System.out.println(str); }} catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { fin.close(); } catch (IOException e) { e.printStackTrace(); } } } }

【Java逐行读取数据】

    推荐阅读