class FileHelper {

    public static <E> void processWithLine(File file, String encoding, Collection<E> result, ObjectProcess<String, E> process) {
        if (result == null) {
            logger.info("receive collection is null");
            return;
        }
        try (
                BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding))
        ) {
            String line;
            while ((line = reader.readLine()) != null) {
                E tmpLine = process.process(line);
                if (tmpLine != null) {
                    result.add(tmpLine);
                }
            }
        } catch (IOException e) {
            logger.error("process error:" + e.getMessage());
            e.printStackTrace();
        }
    }

}