* Assumes UTF-8.
*/
public String getResourceString(String name) {
InputStream in = TranslatorContext.class.getClassLoader().getResourceAsStream(name);
if (in == null)
throw new XMLAnalysisException("Resource not found: " + name, getCurrentOrigin());
BufferedReader reader = null;
try {
StringBuilder sb = new StringBuilder(1000);
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
char[] cb = new char[1024];
int len=0;
while((len = reader.read(cb)) != -1)
sb.append(cb, 0, len);
return sb.toString();
} catch (IOException e) {
throw new XMLAnalysisException(e, getCurrentOrigin());
} finally {
try {
if (reader != null)
reader.close();
} catch (IOException e) {
throw new XMLAnalysisException(e, getCurrentOrigin());
}
}
}