本文整理匯總了Java中java.net.MalformedURLException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java MalformedURLException.getMessage方法的具體用法?Java MalformedURLException.getMessage怎麽用?Java MalformedURLException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.net.MalformedURLException
的用法示例。
在下文中一共展示了MalformedURLException.getMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: unmarshal
import java.net.MalformedURLException; //導入方法依賴的package包/類
public final Object unmarshal( File f ) throws JAXBException {
if( f == null ) {
throw new IllegalArgumentException(
Messages.format( Messages.MUST_NOT_BE_NULL, "file" ) );
}
try {
// copied from JAXP
String path = f.getAbsolutePath();
if (File.separatorChar != '/')
path = path.replace(File.separatorChar, '/');
if (!path.startsWith("/"))
path = "/" + path;
if (!path.endsWith("/") && f.isDirectory())
path = path + "/";
return unmarshal(new URL("file", "", path));
} catch( MalformedURLException e ) {
throw new IllegalArgumentException(e.getMessage());
}
}
示例2: stringToUrl
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* This method transform a given URL in {@link String} format into a {@link URL} object.
* @param string {@link String}
* @return {@link URL}
* @throws JSKException If 'string' param is null.
* @throws JSKException If 'string' param contains a malformed URL.
*/
public static URL stringToUrl(String string) throws JSKException {
if(isNull(string)) {
throw new JSKException(NULL_PARAMETERS);
}
if(voidOrNull(string)) {
throw new JSKException(EMPTY_PARAMETERS);
}
try {
return new URL(string);
}
catch(MalformedURLException exception) {
throw new JSKException(exception.getMessage());
}
}
示例3: urlToContext
import java.net.MalformedURLException; //導入方法依賴的package包/類
private static Context urlToContext(String url, Hashtable<?,?> env)
throws NamingException {
DnsUrl[] urls;
try {
urls = DnsUrl.fromList(url);
} catch (MalformedURLException e) {
throw new ConfigurationException(e.getMessage());
}
if (urls.length == 0) {
throw new ConfigurationException(
"Invalid DNS pseudo-URL(s): " + url);
}
String domain = urls[0].getDomain();
// If multiple urls, all must have the same domain.
for (int i = 1; i < urls.length; i++) {
if (!domain.equalsIgnoreCase(urls[i].getDomain())) {
throw new ConfigurationException(
"Conflicting domains: " + url);
}
}
return getContext(domain, urls, env);
}
示例4: buildUrl
import java.net.MalformedURLException; //導入方法依賴的package包/類
private static URL buildUrl(String urlSpec,
URLStreamHandler handler) {
try {
URLStreamHandler keyHandler;
if (handler == null && urlSpec.startsWith(LEP_PROTOCOL + ":")) {
keyHandler = buildDefaultStreamHandler();
} else {
keyHandler = handler;
}
return new URL(null, urlSpec, keyHandler);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Can't build URL by LEP resource spec: "
+ urlSpec
+ " because of error: "
+ e.getMessage(), e);
}
}
示例5: initUsingCorbanameUrl
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Initializes using "corbaname" URL (INS 99-12-03)
*/
private String initUsingCorbanameUrl(ORB orb, String url, Hashtable<?,?> env)
throws NamingException {
if (orb == null)
orb = getDefaultOrb();
try {
CorbanameUrl parsedUrl = new CorbanameUrl(url);
String corbaloc = parsedUrl.getLocation();
String cosName = parsedUrl.getStringName();
setOrbAndRootContext(orb, corbaloc);
return parsedUrl.getStringName();
} catch (MalformedURLException e) {
throw new ConfigurationException(e.getMessage());
}
}
示例6: getRepository
import java.net.MalformedURLException; //導入方法依賴的package包/類
@Override
/**
* Instantiate and return repository object.
*
*/
public Repository getRepository(RepositoryImplConfig config) throws RepositoryConfigException {
MarkLogicRepository repo = null;
MarkLogicRepositoryConfig cfg = (MarkLogicRepositoryConfig) config;
if (cfg.getHost() != null && cfg.getPort() != 0) {
// init with MarkLogicRepositoryConfig
repo = new MarkLogicRepository(cfg.getHost(),cfg.getPort(),cfg.getUser(),cfg.getPassword(),cfg.getAuth());
} else if (cfg.getHost() == null) {
// init with queryEndpoint as connection string
try {
repo = new MarkLogicRepository(new URL(cfg.getQueryEndpointUrl()));
} catch (MalformedURLException e) {
logger.debug(e.getMessage());
throw new RepositoryConfigException(e.getMessage());
}
}else{
throw new RepositoryConfigException("Invalid configuration class: " + config.getClass());
}
return repo;
}
示例7: safeURL
import java.net.MalformedURLException; //導入方法依賴的package包/類
private static URL safeURL(String urlString) throws ClassNotFoundException {
try {
return new URL(urlString);
} catch (MalformedURLException exception) {
throw new ClassNotFoundException(exception.getMessage());
}
}
示例8: getURI
import java.net.MalformedURLException; //導入方法依賴的package包/類
public String getURI(){
try{
String uri = file.toURL().toString();
if (ref != null && !"".equals(ref)){
uri += '#' + ref;
}
return uri;
} catch(MalformedURLException e){
throw new Error( e.getMessage() );
}
}
示例9: toJavaURL
import java.net.MalformedURLException; //導入方法依賴的package包/類
public java.net.URL toJavaURL() {
try {
return new java.net.URL(toString());
} catch (MalformedURLException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例10: getJettyURL
import java.net.MalformedURLException; //導入方法依賴的package包/類
private static URL getJettyURL(Server server) {
boolean ssl = server.getConnectors()[0].getClass()
== SslSocketConnectorSecure.class;
try {
String scheme = (ssl) ? "https" : "http";
return new URL(scheme + "://" +
server.getConnectors()[0].getHost() + ":" +
server.getConnectors()[0].getLocalPort());
} catch (MalformedURLException ex) {
throw new RuntimeException("It should never happen, " + ex.getMessage(),
ex);
}
}
示例11: parseUrl
import java.net.MalformedURLException; //導入方法依賴的package包/類
private static URL parseUrl(ConfigurationSection section, String path, @Nullable String value, URL def) {
try {
return value == null ? def : new URL(value);
} catch(MalformedURLException e) {
throw new InvalidConfigurationException(section, path, e.getMessage());
}
}
示例12: validateInput
import java.net.MalformedURLException; //導入方法依賴的package包/類
private void validateInput(Input input) {
if(input.getText() == null && input.getUrl() == null) {
throw new IllegalArgumentException("You should provide a text or an URL input");
}
if (input.getText() == null && input.getUrl() != null) {
try {
new URL(input.getUrl());
} catch (MalformedURLException e) {
throw new IllegalArgumentException("URL is not valid: " + e.getMessage());
}
}
if(input.getUrl() == null && input.getText().trim().isEmpty()) {
throw new IllegalArgumentException("Text can't be an empty String.");
}
}
示例13: getJettyURL
import java.net.MalformedURLException; //導入方法依賴的package包/類
/**
* Returns the base URL (SCHEMA://HOST:PORT) of the test Jetty server
* (see {@link #getJettyServer()}) once started.
*
* @return the base URL (SCHEMA://HOST:PORT) of the test Jetty server.
*/
public static URL getJettyURL() {
TestJettyHelper helper = TEST_JETTY_TL.get();
if (helper == null || helper.server == null) {
throw new IllegalStateException("This test does not use @TestJetty");
}
try {
String scheme = (helper.ssl) ? "https" : "http";
return new URL(scheme + "://" +
helper.server.getConnectors()[0].getHost() + ":" +
helper.server.getConnectors()[0].getPort());
} catch (MalformedURLException ex) {
throw new RuntimeException("It should never happen, " + ex.getMessage(), ex);
}
}
示例14: toURL
import java.net.MalformedURLException; //導入方法依賴的package包/類
private URL toURL(String url) {
try {
return new URL(url);
} catch (MalformedURLException malformedURLEx) {
throw new DingtalkNotificationPluginException("Dingtalk API URL is malformed: [" + malformedURLEx.getMessage() + "].", malformedURLEx);
}
}
示例15: setUrl
import java.net.MalformedURLException; //導入方法依賴的package包/類
public void setUrl(String wikiUrl) {
try {
iWikiUrl = new URL(wikiUrl);
} catch (MalformedURLException e) {
throw new RuntimeException(e.getMessage(), e);
}
}