读取TXT文件

mac2022-06-30  32

public static List<Map<String, String>> readTXT(String path)   throws IOException {  //根据路径新建文件对象  File file = new File(path);  //转换为字节流  FileInputStream fis = new FileInputStream(file);  //将字节流转换为字符流  InputStreamReader is = new InputStreamReader(fis, "GBK");  BufferedReader br = new BufferedReader(is);  List<Map<String, String>> list = new ArrayList<Map<String, String>>();  Map<String, String> map = null;  String line = null;  //每次读取一行数据  while ((line = br.readLine()) != null) {   if (line != null && !(line.equals(""))) {//判断该行数据是否为空

}

}

}

转载于:https://www.cnblogs.com/jun021225/p/6307054.html

相关资源:用html javascript读写txt文件
最新回复(0)