今天写了一个读取文件的操作,主要是由于while循环里的操作有点意义,所以记录下来。
public static List<FileVo> getInfoFromFile(FileConfig config) throws Exception{
File file = new File(config.getFilePath());
String splitLine = config.getSplitLine();
String encode = config.getEncode();
String zookeeperUrl = config.getZookeeperUrl();
Map<String,String> map = new HashMap<String,String>();
StringBuffer context = new StringBuffer();
String info = null;
BufferedReader reader = null;
List<FileVo> list = new LinkedList<>();
try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),encode));
while ((info= reader.readLine())!= null){
if (!info.contains("=")&&!info.startsWith(splitLine)){