use of uk.me.parabola.mkgmap.typ.TypTextReader in project mkgmap by openstreetmap.
the class TypCompiler method compile.
/**
* Read and compile a TYP file, returning the compiled form.
*
* @param filename The input filename.
* @param charset The character set to use to read this file. We should have already determined
* that this character set is valid and can be used to read the file.
* @param sort The sort information from command line options, used for the output code page
* only. If null, then the code page set by CodePage in the typ.txt file will be used.
*
* @return The compiled form as a data structure.
* @throws FileNotFoundException If the file doesn't exist.
* @throws SyntaxException All user correctable problems in the input file.
*/
private TypData compile(String filename, String charset, Sort sort) throws FileNotFoundException, SyntaxException {
TypTextReader tr = new TypTextReader();
TypData data = tr.getData();
data.setSort(sort);
try {
Reader r = new BufferedReader(new InputStreamReader(new FileInputStream(filename), charset));
try {
tr.read(filename, r);
} finally {
Utils.closeFile(r);
}
} catch (UnsupportedEncodingException e) {
// Not likely to happen as we should have already used this character set!
throw new MapFailedException("Unsupported character set", e);
}
return tr.getData();
}
Aggregations