Used to read the project file, but there are some very large files. Immediately added to the recycling of memory to take, efficiency is at the end, try to use sub-read, this method is feasible. Paste the code out, If you have a better way. Please correct me.
public static List <Keyword> readFile (int formIndex, int toIndex) (
List <Keyword> lists = new ArrayList <Keyword> ();
String path = getPadFilePath ();
FileReader fr = new FileReader (path);
BufferedReader br = new BufferedReader (fr);
int i = 0;
while ((temp = br.readLine ())! = null) (
i + +;
if (i> formIndex & & i <toIndex) (
lists.add (new Keyword (temp));
) Catch (Exception e) (
log.error ( "read file exception:" + getExceptionStr (e));
Note: fromIndex - the starting position. toIndex --- end of the position.
Previously, the practice is to use the List, there is a subList way, this can be achieved, but the aim is different. If that's the case. Done is very simple.