URL implements Serializable { public String getAbsolutePath() { if (path != null && !path.startsWith("/")) { return "/" + path; } return path; } protected  URL();  URL(String protocol, String host, int port);  URL(String protocol, String host, int port, String[] pairs);  URL(String protocol, String host, int port, Map<String, String> parameters);  URL(String protocol, String host, int port, String path);  URL(String protocol, String host, int port, String path, String... pairs);  URL(String protocol, String host, int port, String path, Map<String, String> parameters);  URL(String protocol, String username, String password, String host, int port, String path);  URL(String protocol, String username, String password, String host, int port, String path, String... pairs);  URL(String protocol,
               String username,
               String password,
               String host,
               int port,
               String path,
               Map<String, String> parameters);  URL(String protocol,
               String username,
               String password,
               String host,
               int port,
               String path,
               Map<String, String> parameters,
               Map<String, Map<String, String>> methodParameters); static URL valueOf(String url); static Map<String, Map<String, String>> toMethodParameters(Map<String, String> parameters); static URL valueOf(String url, String... reserveParams); static URL valueOf(URL url, String[] reserveParams, String[] reserveParamPrefixs); static String encode(String value); static String decode(String value); String getProtocol(); URL setProtocol(String protocol); String getUsername(); URL setUsername(String username); String getPassword(); URL setPassword(String password); String getAuthority(); String getHost(); URL setHost(String host); String getIp(); int getPort(); URL setPort(int port); int getPort(int defaultPort); String getAddress(); URL setAddress(String address); String getBackupAddress(); String getBackupAddress(int defaultPort); List<URL> getBackupUrls(); String getPath(); URL setPath(String path); String getAbsolutePath(); Map<String, String> getParameters(); Map<String, String> getParameters(Predicate<String> nameToSelect); T getParameter(String key, Class<T> valueType); T getParameter(String key, Class<T> valueType, T defaultValue); Map<String, Map<String, String>> getMethodParameters(); String getParameterAndDecoded(String key); String getParameterAndDecoded(String key, String defaultValue); String getParameter(String key); String getParameter(String key, String defaultValue); String[] getParameter(String key, String[] defaultValue); List<String> getParameter(String key, List<String> defaultValue); URL getUrlParameter(String key); double getParameter(String key, double defaultValue); float getParameter(String key, float defaultValue); long getParameter(String key, long defaultValue); int getParameter(String key, int defaultValue); short getParameter(String key, short defaultValue); byte getParameter(String key, byte defaultValue); float getPositiveParameter(String key, float defaultValue); double getPositiveParameter(String key, double defaultValue); long getPositiveParameter(String key, long defaultValue); int getPositiveParameter(String key, int defaultValue); short getPositiveParameter(String key, short defaultValue); byte getPositiveParameter(String key, byte defaultValue); char getParameter(String key, char defaultValue); boolean getParameter(String key, boolean defaultValue); boolean hasParameter(String key); String getMethodParameterAndDecoded(String method, String key); String getMethodParameterAndDecoded(String method, String key, String defaultValue); String getMethodParameterStrict(String method, String key); String getMethodParameter(String method, String key); String getMethodParameter(String method, String key, String defaultValue); double getMethodParameter(String method, String key, double defaultValue); float getMethodParameter(String method, String key, float defaultValue); long getMethodParameter(String method, String key, long defaultValue); int getMethodParameter(String method, String key, int defaultValue); short getMethodParameter(String method, String key, short defaultValue); byte getMethodParameter(String method, String key, byte defaultValue); double getMethodPositiveParameter(String method, String key, double defaultValue); float getMethodPositiveParameter(String method, String key, float defaultValue); long getMethodPositiveParameter(String method, String key, long defaultValue); int getMethodPositiveParameter(String method, String key, int defaultValue); short getMethodPositiveParameter(String method, String key, short defaultValue); byte getMethodPositiveParameter(String method, String key, byte defaultValue); char getMethodParameter(String method, String key, char defaultValue); boolean getMethodParameter(String method, String key, boolean defaultValue); boolean hasMethodParameter(String method, String key); boolean hasMethodParameter(String method); boolean isLocalHost(); boolean isAnyHost(); URL addParameterAndEncoded(String key, String value); URL addParameter(String key, boolean value); URL addParameter(String key, char value); URL addParameter(String key, byte value); URL addParameter(String key, short value); URL addParameter(String key, int value); URL addParameter(String key, long value); URL addParameter(String key, float value); URL addParameter(String key, double value); URL addParameter(String key, Enum<?> value); URL addParameter(String key, Number value); URL addParameter(String key, CharSequence value); URL addParameter(String key, String value); URL addParameterIfAbsent(String key, String value); URL addMethodParameter(String method, String key, String value); URL addMethodParameterIfAbsent(String method, String key, String value); URL addParameters(Map<String, String> parameters); URL addParametersIfAbsent(Map<String, String> parameters); URL addParameters(String... pairs); URL addParameterString(String query); URL removeParameter(String key); URL removeParameters(Collection<String> keys); URL removeParameters(String... keys); URL clearParameters(); String getRawParameter(String key); Map<String, String> toMap(); @Override String toString(); String toString(String... parameters); String toIdentityString(); String toIdentityString(String... parameters); String toFullString(); String toFullString(String... parameters); String toParameterString(); String toParameterString(String... parameters); java.net.URL toJavaURL(); InetSocketAddress toInetSocketAddress(); String getColonSeparatedKey(); String getServiceKey(); String getPathKey(); static String buildKey(String path, String group, String version); String getProtocolServiceKey(); String toServiceStringWithoutResolving(); String toServiceString(); @Deprecated String getServiceName(); String getServiceInterface(); URL setServiceInterface(String service); @Deprecated int getIntParameter(String key); @Deprecated int getIntParameter(String key, int defaultValue); @Deprecated int getPositiveIntParameter(String key, int defaultValue); @Deprecated boolean getBooleanParameter(String key); @Deprecated boolean getBooleanParameter(String key, boolean defaultValue); @Deprecated int getMethodIntParameter(String method, String key); @Deprecated int getMethodIntParameter(String method, String key, int defaultValue); @Deprecated int getMethodPositiveIntParameter(String method, String key, int defaultValue); @Deprecated boolean getMethodBooleanParameter(String method, String key); @Deprecated boolean getMethodBooleanParameter(String method, String key, boolean defaultValue); Configuration toConfiguration(); @Override int hashCode(); @Override boolean equals(Object obj); static void putMethodParameter(String method, String key, String value, Map<String, Map<String, String>> methodParameters); Map<String, String> getServiceParameters(String service); String getServiceParameter(String service, String key); String getServiceParameter(String service, String key, String defaultValue); int getServiceParameter(String service, String key, int defaultValue); double getServiceParameter(String service, String key, double defaultValue); float getServiceParameter(String service, String key, float defaultValue); long getServiceParameter(String service, String key, long defaultValue); short getServiceParameter(String service, String key, short defaultValue); byte getServiceParameter(String service, String key, byte defaultValue); char getServiceParameter(String service, String key, char defaultValue); boolean getServiceParameter(String service, String key, boolean defaultValue); boolean hasServiceParameter(String service, String key); float getPositiveServiceParameter(String service, String key, float defaultValue); double getPositiveServiceParameter(String service, String key, double defaultValue); long getPositiveServiceParameter(String service, String key, long defaultValue); int getPositiveServiceParameter(String service, String key, int defaultValue); short getPositiveServiceParameter(String service, String key, short defaultValue); byte getPositiveServiceParameter(String service, String key, byte defaultValue); String getServiceMethodParameterAndDecoded(String service, String method, String key); String getServiceMethodParameterAndDecoded(String service, String method, String key, String defaultValue); String getServiceMethodParameterStrict(String service, String method, String key); String getServiceMethodParameter(String service, String method, String key); String getServiceMethodParameter(String service, String method, String key, String defaultValue); double getServiceMethodParameter(String service, String method, String key, double defaultValue); float getServiceMethodParameter(String service, String method, String key, float defaultValue); long getServiceMethodParameter(String service, String method, String key, long defaultValue); int getServiceMethodParameter(String service, String method, String key, int defaultValue); short getMethodParameter(String service, String method, String key, short defaultValue); byte getServiceMethodParameter(String service, String method, String key, byte defaultValue); boolean hasServiceMethodParameter(String service, String method, String key); boolean hasServiceMethodParameter(String service, String method);  }
@Test public void test_getAbsolutePath() throws Exception { URL url = new URL("p1", "1.2.2.2", 33); assertURLStrDecoder(url); assertNull(url.getAbsolutePath()); url = new URL("file", null, 90, "/home/user1/route.js"); assertURLStrDecoder(url); assertEquals("/home/user1/route.js", url.getAbsolutePath()); }