35 import sun.net.www.ParseUtil; 36 37 /** 38 * The abstract class {@code URLStreamHandler} is the common 39 * superclass for all stream protocol handlers. A stream protocol 40 * handler knows how to make a connection for a particular protocol 41 * type, such as {@code http} or {@code https}. 42 * <p> 43 * In most cases, an instance of a {@code URLStreamHandler} 44 * subclass is not created directly by an application. Rather, the 45 * first time a protocol name is encountered when constructing a 46 * {@code URL}, the appropriate stream protocol handler is 47 * automatically loaded. 48 * 49 * @author James Gosling 50 * @see java.net.URL#URL(java.lang.String, java.lang.String, int, java.lang.String) 51 * @since 1.0 52 */ 53 public abstract class URLStreamHandler { 54 /** 55 * Opens a connection to the object referenced by the 56 * {@code URL} argument. 57 * This method should be overridden by a subclass. 58 * 59 * <p>If for the handler's protocol (such as HTTP or JAR), there 60 * exists a public, specialized URLConnection subclass belonging 61 * to one of the following packages or one of their subpackages: 62 * java.lang, java.io, java.util, java.net, the connection 63 * returned will be of that subclass. For example, for HTTP an 64 * HttpURLConnection will be returned, and for JAR a 65 * JarURLConnection will be returned. 66 * 67 * @param u the URL that this connects to. 68 * @return a {@code URLConnection} object for the {@code URL}. 69 * @throws IOException if an I/O error occurs while opening the 70 * connection. 71 */ 72 protected abstract URLConnection openConnection(URL u) throws IOException; 73 74 /** | 35 import sun.net.www.ParseUtil; 36 37 /** 38 * The abstract class {@code URLStreamHandler} is the common 39 * superclass for all stream protocol handlers. A stream protocol 40 * handler knows how to make a connection for a particular protocol 41 * type, such as {@code http} or {@code https}. 42 * <p> 43 * In most cases, an instance of a {@code URLStreamHandler} 44 * subclass is not created directly by an application. Rather, the 45 * first time a protocol name is encountered when constructing a 46 * {@code URL}, the appropriate stream protocol handler is 47 * automatically loaded. 48 * 49 * @author James Gosling 50 * @see java.net.URL#URL(java.lang.String, java.lang.String, int, java.lang.String) 51 * @since 1.0 52 */ 53 public abstract class URLStreamHandler { 54 /** 55 * Constructor for subclasses to call. 56 */ 57 public URLStreamHandler() {} 58 59 /** 60 * Opens a connection to the object referenced by the 61 * {@code URL} argument. 62 * This method should be overridden by a subclass. 63 * 64 * <p>If for the handler's protocol (such as HTTP or JAR), there 65 * exists a public, specialized URLConnection subclass belonging 66 * to one of the following packages or one of their subpackages: 67 * java.lang, java.io, java.util, java.net, the connection 68 * returned will be of that subclass. For example, for HTTP an 69 * HttpURLConnection will be returned, and for JAR a 70 * JarURLConnection will be returned. 71 * 72 * @param u the URL that this connects to. 73 * @return a {@code URLConnection} object for the {@code URL}. 74 * @throws IOException if an I/O error occurs while opening the 75 * connection. 76 */ 77 protected abstract URLConnection openConnection(URL u) throws IOException; 78 79 /** |