com.netsensia.rivalchess.util.EpdReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rivalchess-engine Show documentation
Show all versions of rivalchess-engine Show documentation
The engine used by Rival Chess
package com.netsensia.rivalchess.util;
import com.netsensia.rivalchess.exception.IllegalEpdItemException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class EpdReader implements Iterable {
private final List epdItems = new ArrayList<>();
public EpdReader(String filename) throws IOException, IllegalEpdItemException {
File file = new File(filename);
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String line;
while ((line = br.readLine()) != null) {
if (!line.trim().equals("")) {
epdItems.add(new EpdItem(line));
}
}
fr.close();
}
public int size() {
return epdItems.size();
}
@Override
public Iterator iterator() {
return epdItems.iterator();
}
}