org.daisy.pipeline.nlp.impl.ResourceUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nlp-common Show documentation
Show all versions of nlp-common Show documentation
Common API for NLP functionality and XProc steps
The newest version!
package org.daisy.pipeline.nlp.impl;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import com.google.common.base.Charsets;
public class ResourceUtils {
public static Collection readLines(String directory, String filename)
throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(ResourceUtils.class
.getResourceAsStream("/" + directory + "/" + filename), Charsets.UTF_8));
ArrayList res = new ArrayList();
String line = reader.readLine();
while (line != null) {
String str = line.trim();
if (str.length() > 0)
res.add(str);
line = reader.readLine();
}
return res;
}
}