This doesn't seem to be properly documented somewhere.
Javadoc ClassLoader.getResourceAsStream , getResourceAsStream , getResource, URL.openStream URL-, Javadoc getResource, URL. .
public InputStream getResourceAsStream(String name)
. getResource(String).
URL.openStream :
public final InputStream openStream() throws IOException
URL- InputStream . : openConnection().getInputStream()
, URL.openConnection() URLConnection , , , FileURLConnection, getInputStream.
, URL file:/// , InputStream . ( , - , )
public synchronized InputStream getInputStream()
throws IOException {
int iconHeight;
int iconWidth;
connect();
if (is == null) {
if (isDirectory) {
FileNameMap map = java.net.URLConnection.getFileNameMap();
StringBuffer buf = new StringBuffer();
if (files == null) {
throw new FileNotFoundException(filename);
}
Collections.sort(files, Collator.getInstance());
for (int i = 0 ; i < files.size() ; i++) {
String fileName = files.get(i);
buf.append(fileName);
buf.append("\n");
}
is = new ByteArrayInputStream(buf.toString().getBytes());
} else {
throw new FileNotFoundException(filename);
}
}
return is;
}
:
, , , .