package cn.edu.seu.ise.dca.util;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

public class FileUtil {
	
	/**
	 * Split the file into lines
	 * @param filePath specifies the file path
	 * @return
	 */
	public static List<String> fileToLines(String filePath) {
		List<String> lines = new LinkedList<String>();
		String line = "";
		try {
			BufferedReader in = new BufferedReader(new FileReader(filePath));
			while ((line = in.readLine()) != null) {
				lines.add(line);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return lines;
	}
	
	/**
	 * Calculate the code lines of a file
	 * @param filePath
	 * @return
	 */
	public static long getLines(String filePath) {
		return fileToLines(filePath).size();
	}
	

	public static String GetFullName(String prefix, String name) {
		return prefix + "->" + name;
	}

}
