本文整理匯總了Java中java.net.URI.getRawSchemeSpecificPart方法的典型用法代碼示例。如果您正苦於以下問題:Java URI.getRawSchemeSpecificPart方法的具體用法?Java URI.getRawSchemeSpecificPart怎麽用?Java URI.getRawSchemeSpecificPart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.net.URI
的用法示例。
在下文中一共展示了URI.getRawSchemeSpecificPart方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFileName
import java.net.URI; //導入方法依賴的package包/類
/**
* Returns the file name of the resource references by the URI. Works with jar: URIs, which normally return
* {@code null} if the {@link URI#getPath()} call is used.
* @param uri
* @return The filename, if it can be calculated.
* @throws IllegalArgumentException if the filename cannot be calculated (e.g. if the scheme is not understood).
*/
public static String getFileName(URI uri) throws IllegalArgumentException {
String filename;
if (JAR_URI_SCHEME.equals(uri.getScheme())) {
String ssp = uri.getRawSchemeSpecificPart();
String innerPath;
int bang = ssp.indexOf('!');
if (bang < 0) {
throw new IllegalArgumentException("Invalid jar content URI; missing '!/' path separator: " + uri);
} else {
innerPath = ssp.substring(bang + 1);
}
filename = getPathLastSegment(innerPath);
} else {
String path = uri.getPath();
if (path == null) {
throw new IllegalArgumentException("Cannot calculate filename for unknown opaque URI scheme: " + uri);
}
filename = getPathLastSegment(path);
}
return filename;
}
示例2: uriToPath
import java.net.URI; //導入方法依賴的package包/類
protected Path uriToPath(URI uri) {
String scheme = uri.getScheme();
if ((scheme == null) || !scheme.equalsIgnoreCase(getScheme())) {
throw new IllegalArgumentException("URI scheme is not '" + getScheme() + "'");
}
try {
// only support legacy JAR URL syntax jar:{uri}!/{entry} for now
String spec = uri.getRawSchemeSpecificPart();
int sep = spec.indexOf("!/");
if (sep != -1)
spec = spec.substring(0, sep);
return Paths.get(new URI(spec)).toAbsolutePath();
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
示例3: uriToPath
import java.net.URI; //導入方法依賴的package包/類
protected Path uriToPath(URI uri) {
String scheme = uri.getScheme();
if ((scheme == null) || !scheme.equalsIgnoreCase(getScheme())) {
throw new IllegalArgumentException("URI scheme is not '" + getScheme() + "'");
}
try {
// only support legacy JAR URL syntax jar:{uri}!/{entry} for now
String spec = uri.getRawSchemeSpecificPart();
int sep = spec.indexOf("!/");
if (sep != -1) {
spec = spec.substring(0, sep);
}
return Paths.get(new URI(spec)).toAbsolutePath();
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
示例4: digestURI
import java.net.URI; //導入方法依賴的package包/類
private void digestURI(final URI uri) {
this.scheme = uri.getScheme();
this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
this.encodedAuthority = uri.getRawAuthority();
this.host = uri.getHost();
this.port = uri.getPort();
this.encodedUserInfo = uri.getRawUserInfo();
this.userInfo = uri.getUserInfo();
this.encodedPath = uri.getRawPath();
this.path = uri.getPath();
this.encodedQuery = uri.getRawQuery();
this.queryParams = parseQuery(uri.getRawQuery(), Charset.forName(HTTP.UTF_8));
this.encodedFragment = uri.getRawFragment();
this.fragment = uri.getFragment();
}
示例5: digestURI
import java.net.URI; //導入方法依賴的package包/類
private void digestURI(final URI uri) {
this.scheme = uri.getScheme();
this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
this.encodedAuthority = uri.getRawAuthority();
this.host = uri.getHost();
this.port = uri.getPort();
this.encodedUserInfo = uri.getRawUserInfo();
this.userInfo = uri.getUserInfo();
this.encodedPath = uri.getRawPath();
this.path = uri.getPath();
this.encodedQuery = uri.getRawQuery();
this.queryParams = parseQuery(uri.getRawQuery(), Consts.UTF_8);
this.encodedFragment = uri.getRawFragment();
this.fragment = uri.getFragment();
}