Title: Method for returning the base URL of a java.net.URL object Author: Bruno Borges Organization: Oracle Owner: Bruno Borges Created: 2013/01/15 Type: Feature State: Draft Exposure: Open Component: core/net Scope: SE JSR: 337 Discussion: net dash dev at openjdk dot java dot net Start: 2013/Q1 Effort: XS Duration: XS Template: 1.0
Method for returning the base URL of a given URL object, as of 'protocol://host:port'.
Boiler-plate code is needed to extract the base URL of a given URL object. This method will standardize and provide a basic feature.
The java.net.URL class should provide a getBaseURL method that returns another URL object, based on the protocol://hostname:port of the original URL object. Nothing else should be added to the base URL object, for example path or query string.
Given the following URL: http://openjdk.java.net/jeps/1, the getBaseURL method must return a URL object representing "http://openjdk.java.net"
- User experience: no need to create boiler-plate code, or use 3rd-party libraries.