in src/main/java/org/apache/bsf/util/StringUtils.java [137:166]
public static Reader getContentAsReader(final URL url) throws SecurityException, IllegalArgumentException, IOException {
if (url == null) {
throw new IllegalArgumentException("URL cannot be null.");
}
try {
final Object content = url.getContent();
if (content == null) {
throw new IllegalArgumentException("No content.");
}
if (content instanceof InputStream) {
final Reader in = new InputStreamReader((InputStream) content);
if (in.ready()) {
return in;
} else {
throw new FileNotFoundException();
}
} else {
throw new IllegalArgumentException(
(content instanceof String) ? (String) content : "This URL points to a: " + StringUtils.getClassName(content.getClass()));
}
} catch (final SecurityException e) {
throw new SecurityException("Your JVM's SecurityManager has disallowed this.");
} catch (final FileNotFoundException e) {
throw new FileNotFoundException("This file was not found: " + url);
}
}