in velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/ImportSupport.java [521:560]
public Reader getResourceReader(String resource)
{
getLog().debug("get resource {}", resource);
URL url = null;
Reader reader = null;
try
{
url = getFileResource(resource);
if (url == null)
{
url = getClasspathResource(resource);
}
if (url != null)
{
URLConnection uc = url.openConnection();
InputStream is = uc.getInputStream();
String charSet;
// charSet extracted according to RFC 2045, section 5.1
String contentType = uc.getContentType();
if (contentType != null)
{
charSet = ImportSupport.getContentTypeAttribute(contentType, "charset");
if (charSet == null)
{
charSet = RuntimeConstants.ENCODING_DEFAULT;
}
}
else
{
charSet = RuntimeConstants.ENCODING_DEFAULT;
}
reader = new InputStreamReader(is, charSet);
}
}
catch (Exception e)
{
getLog().error("could not get resource {}", resource, e);
}
return reader;
}