📄 testfactory.java
字号:
import java.net.*;import java.util.Hashtable;public class TestFactory implements URLStreamHandlerFactory { static Hashtable handlers = new Hashtable(); public URLStreamHandler createURLStreamHandler(String protocol) { // try cached handlers first URLStreamHandler handler = (URLStreamHandler)handlers.get(protocol); if (handler == null) { String className = "Test" + protocol + "Handler"; try { handler = (URLStreamHandler)Class. forName(className).newInstance(); } catch (ClassNotFoundException e) { handler = null; // not found } catch (Exception e) { // all other exceptions, print out problem e.printStackTrace(); handler = null; } if (handler != null) handlers.put(protocol, handler); // put into cache } return (handler); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -