if (textFile.getName().endsWith(".gz")) is = new GZIPInputStream(is);
BufferedReader reader = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
String line;
while ((line = reader.readLine()) != null) {
NGram ngram = new NGram();
for (char c : line.toCharArray()) {
ngram.addChar((char) c);
for (int i = 1; i <= NGram.N_GRAM; i++) {
profile.add(ngram.get(i));
}
}
}
} catch (IOException e) {
throw new LangDetectException(ErrorCode.CantOpenTrainData, "Can't open training database file '" + textFile.getName() + "'");