package tool;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class ReadFile {
/**
- 以行为单位读取文件,常用于读面向行的格式化文件 */ public ArrayList<String[]> readFile(String fileName) { BufferedReader reader =null;ArrayList<String[]> list = new ArrayList<String[]>();try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName),"UTF-8"));String tempString = null; // 一次读入一行,直到读入null为文件结束 while ((tempString = reader.readLine()) != null) { // 显示行号 String[] str=tempString.split("=");list.add(str);} reader.close();} catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e1) { }}}return list; }}