...
Compliant Solution (Accessible Class Variable)
If a program another class intends to use System.in as well as this the InputLibrary class InputLibrary, the program class must use the same buffered wrapper as does this class rather than which is used by InputLibrary, instead of creating and using its own additional buffered wrapper. Consequently, library InputLibrary must make available a reference to the buffered wrapper to support this functionalityfor such classes.
| Code Block | ||
|---|---|---|
| ||
public final class InputLibrary {
private static BufferedInputStream in = new BufferedInputStream(System.in);
static BufferedInputStream getBufferedWrapper() {
return in;
}
// ...other methods
}
// Some code that requires user input from System.in
class AppCode {
private static BufferedInputStream in;
AppCode() {
in = InputLibrary.getBufferedWrapper();
}
// ...other methods
}
|
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5d7ebf3acbdd323a-c2ff89f3-4f67455b-99cca888-0e5f012b76da17f97767177d"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | [method read | http://java.sun.com/javase/6/docs/api/java/io/InputStream.html#read()] | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="af762b01f6afb23d-df07535a-422249d6-9e2fb2e9-638d3951f14a3f2ae58f093c"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | [class BufferedInputStream | http://java.sun.com/javase/6/docs/api/java/io/BufferedInputStream.html] | ]]></ac:plain-text-body></ac:structured-macro> |
...