308 * |
308 * |
309 * @param protocol the name of the protocol to use. |
309 * @param protocol the name of the protocol to use. |
310 * @param host the name of the host. |
310 * @param host the name of the host. |
311 * @param port the port number on the host. |
311 * @param port the port number on the host. |
312 * @param file the file on the host |
312 * @param file the file on the host |
313 * @exception MalformedURLException if an unknown protocol is specified. |
313 * @exception MalformedURLException if an unknown protocol or the port |
|
314 * is a negative number other than -1 |
314 * @see java.lang.System#getProperty(java.lang.String) |
315 * @see java.lang.System#getProperty(java.lang.String) |
315 * @see java.net.URL#setURLStreamHandlerFactory( |
316 * @see java.net.URL#setURLStreamHandlerFactory( |
316 * java.net.URLStreamHandlerFactory) |
317 * java.net.URLStreamHandlerFactory) |
317 * @see java.net.URLStreamHandler |
318 * @see java.net.URLStreamHandler |
318 * @see java.net.URLStreamHandlerFactory#createURLStreamHandler( |
319 * @see java.net.URLStreamHandlerFactory#createURLStreamHandler( |
327 /** |
328 /** |
328 * Creates a URL from the specified {@code protocol} |
329 * Creates a URL from the specified {@code protocol} |
329 * name, {@code host} name, and {@code file} name. The |
330 * name, {@code host} name, and {@code file} name. The |
330 * default port for the specified protocol is used. |
331 * default port for the specified protocol is used. |
331 * <p> |
332 * <p> |
332 * This method is equivalent to calling the four-argument |
333 * This constructor is equivalent to the four-argument |
333 * constructor with the arguments being {@code protocol}, |
334 * constructor with the only difference of using the |
334 * {@code host}, {@code -1}, and {@code file}. |
335 * default port for the specified protocol. |
335 * |
336 * |
336 * No validation of the inputs is performed by this constructor. |
337 * No validation of the inputs is performed by this constructor. |
337 * |
338 * |
338 * @param protocol the name of the protocol to use. |
339 * @param protocol the name of the protocol to use. |
339 * @param host the name of the host. |
340 * @param host the name of the host. |
370 * @param protocol the name of the protocol to use. |
371 * @param protocol the name of the protocol to use. |
371 * @param host the name of the host. |
372 * @param host the name of the host. |
372 * @param port the port number on the host. |
373 * @param port the port number on the host. |
373 * @param file the file on the host |
374 * @param file the file on the host |
374 * @param handler the stream handler for the URL. |
375 * @param handler the stream handler for the URL. |
375 * @exception MalformedURLException if an unknown protocol is specified. |
376 * @exception MalformedURLException if an unknown protocol or the port |
|
377 is a negative number other than -1 |
376 * @exception SecurityException |
378 * @exception SecurityException |
377 * if a security manager exists and its |
379 * if a security manager exists and its |
378 * {@code checkPermission} method doesn't allow |
380 * {@code checkPermission} method doesn't allow |
379 * specifying a stream handler explicitly. |
381 * specifying a stream handler explicitly. |
380 * @see java.lang.System#getProperty(java.lang.String) |
382 * @see java.lang.System#getProperty(java.lang.String) |
444 * This constructor is equivalent to a call to the two-argument |
446 * This constructor is equivalent to a call to the two-argument |
445 * constructor with a {@code null} first argument. |
447 * constructor with a {@code null} first argument. |
446 * |
448 * |
447 * @param spec the {@code String} to parse as a URL. |
449 * @param spec the {@code String} to parse as a URL. |
448 * @exception MalformedURLException if no protocol is specified, or an |
450 * @exception MalformedURLException if no protocol is specified, or an |
449 * unknown protocol is found, or {@code spec} is {@code null}. |
451 * unknown protocol is found, or {@code spec} is {@code null}, |
|
452 * or the parsed URL fails to comply with the specific syntax |
|
453 * of the associated protocol. |
450 * @see java.net.URL#URL(java.net.URL, java.lang.String) |
454 * @see java.net.URL#URL(java.net.URL, java.lang.String) |
451 */ |
455 */ |
452 public URL(String spec) throws MalformedURLException { |
456 public URL(String spec) throws MalformedURLException { |
453 this(null, spec); |
457 this(null, spec); |
454 } |
458 } |
491 * For a more detailed description of URL parsing, refer to RFC2396. |
495 * For a more detailed description of URL parsing, refer to RFC2396. |
492 * |
496 * |
493 * @param context the context in which to parse the specification. |
497 * @param context the context in which to parse the specification. |
494 * @param spec the {@code String} to parse as a URL. |
498 * @param spec the {@code String} to parse as a URL. |
495 * @exception MalformedURLException if no protocol is specified, or an |
499 * @exception MalformedURLException if no protocol is specified, or an |
496 * unknown protocol is found, or {@code spec} is {@code null}. |
500 * unknown protocol is found, or {@code spec} is {@code null}, |
|
501 * or the parsed URL fails to comply with the specific syntax |
|
502 * of the associated protocol. |
497 * @see java.net.URL#URL(java.lang.String, java.lang.String, |
503 * @see java.net.URL#URL(java.lang.String, java.lang.String, |
498 * int, java.lang.String) |
504 * int, java.lang.String) |
499 * @see java.net.URLStreamHandler |
505 * @see java.net.URLStreamHandler |
500 * @see java.net.URLStreamHandler#parseURL(java.net.URL, |
506 * @see java.net.URLStreamHandler#parseURL(java.net.URL, |
501 * java.lang.String, int, int) |
507 * java.lang.String, int, int) |
511 * |
517 * |
512 * @param context the context in which to parse the specification. |
518 * @param context the context in which to parse the specification. |
513 * @param spec the {@code String} to parse as a URL. |
519 * @param spec the {@code String} to parse as a URL. |
514 * @param handler the stream handler for the URL. |
520 * @param handler the stream handler for the URL. |
515 * @exception MalformedURLException if no protocol is specified, or an |
521 * @exception MalformedURLException if no protocol is specified, or an |
516 * unknown protocol is found, or {@code spec} is {@code null}. |
522 * unknown protocol is found, or {@code spec} is {@code null}, |
|
523 * or the parsed URL fails to comply with the specific syntax |
|
524 * of the associated protocol. |
517 * @exception SecurityException |
525 * @exception SecurityException |
518 * if a security manager exists and its |
526 * if a security manager exists and its |
519 * {@code checkPermission} method doesn't allow |
527 * {@code checkPermission} method doesn't allow |
520 * specifying a stream handler. |
528 * specifying a stream handler. |
521 * @see java.net.URL#URL(java.lang.String, java.lang.String, |
529 * @see java.net.URL#URL(java.lang.String, java.lang.String, |