java - Does this code pass a value to var? -
there following code https://github.com/nanohttpd/nanohttpd/blob/master/webserver/src/main/java/fi/iki/elonen/simplewebserver.java.
does code static {mimetypes(); ...} pass value var licence?  valid java syntax? when var licence  passed value? runtime or compile-time ?
/**  * distribution licence  */ private static final string licence; static {     mimetypes();     string text;     try {         inputstream stream = simplewebserver.class.getresourceasstream("/license.txt");         bytearrayoutputstream bytes = new bytearrayoutputstream();         byte[] buffer = new byte[1024];         int count;         while ((count = stream.read(buffer)) >= 0) {             bytes.write(buffer, 0, count);         }         text = bytes.tostring("utf-8");     } catch (exception e) {         text = "unknown";     }     licence = text; } 
the static { static initializer block. code run once when class loaded.
license set value of text, obtained bytes.tostring().
it set @ runtime.
Comments
Post a Comment