java.net.MalformedURLException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中java.net.MalformedURLException.getMessage()方法的一些代码示例,展示了MalformedURLException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MalformedURLException.getMessage()方法的具体详情如下:
包路径:java.net.MalformedURLException
类名称:MalformedURLException
方法名:getMessage

MalformedURLException.getMessage介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-dubbo

public java.net.URL toJavaURL() {
  try {
    return new java.net.URL(toString());
  } catch (MalformedURLException e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}

代码示例来源:origin: plutext/docx4j

/**
 * @param file file to handle
 * @param depth recursion depth
 * @param results collection
 * {@inheritDoc}
 */
protected void handleFile(File file, int depth, Collection results) {
  try {
    // Looks Strange, but is actually recommended over just .URL()
    results.add(file.toURI().toURL());
  } catch (MalformedURLException e) {
    log.debug("MalformedURLException" + e.getMessage());
  }
}

代码示例来源:origin: chewiebug/GCViewer

private String getResourceUrlString(String resource) {
  URL url = null;
  try {
    if (resource.startsWith("http") || resource.startsWith("file")) {
      url = new URL(resource);
    }
    else {
      url = new File(resource).toURI().toURL();
    }
  }
  catch (MalformedURLException ex) {
    logger.log(Level.WARNING, "Failed to determine URL of " + resource + ". Reason: " + ex.getMessage());
    logger.log(Level.FINER, "Details: ", ex);
  }
  return url != null ? url.toString() : null;
}

代码示例来源:origin: apache/incubator-dubbo

public java.net.URL toJavaURL() {
  try {
    return new java.net.URL(toString());
  } catch (MalformedURLException e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}

代码示例来源:origin: hibernate/hibernate-orm

jarUrl = new URL( file );
  if ( "file".equals( jarUrl.getProtocol() ) ) {
    if ( file.indexOf( ' ' ) != -1 ) {
      jarUrl = new File( jarUrl.getFile() ).toURI().toURL();
    jarUrl = new File(file).toURI().toURL();
    jarUrl = new URL( protocol, url.getHost(), url.getPort(), file );
    "Unable to determine JAR Url from " + url + ". Cause: " + e.getMessage()
);

代码示例来源:origin: twosigma/beakerx

public void addJars(List<String> dirs) {
 for (String dir : dirs) {
  try {
   myloader.addJar(Paths.get(dir).toUri().toURL());
  } catch (MalformedURLException e) {
   logger.error(e.getMessage());
  }
 }
}

代码示例来源:origin: spring-projects/spring-security-oauth

private URL toURL(String urlStr) {
    try {
      return new URL(urlStr);
    } catch (MalformedURLException ex) {
      throw new IllegalArgumentException("Unable to convert '" + urlStr + "' to URL: " + ex.getMessage(), ex);
    }
  }
}

代码示例来源:origin: igniterealtime/Openfire

addURL(classesDir.toURI().toURL());
  addURL(databaseDir.toURI().toURL());
  addURL(i18nDir.toURI().toURL());
          addURLFile(new URL("jar", "", -1, jarFileUri));
        addURLFile(new URL("jar", "", -1, jarFileUri));
Log.error(mue.getMessage(), mue);

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Get the pathname to the webapps files.
 * @param appName eg "secondary" or "datanode"
 * @return the pathname as a URL
 * @throws FileNotFoundException if 'webapps' directory cannot be found
 *   on CLASSPATH or in the development location.
 */
protected String getWebAppsPath(String appName) throws FileNotFoundException {
 URL resourceUrl = null;
 File webResourceDevLocation = new File("src/main/webapps", appName);
 if (webResourceDevLocation.exists()) {
  LOG.info("Web server is in development mode. Resources "
    + "will be read from the source tree.");
  try {
   resourceUrl = webResourceDevLocation.getParentFile().toURI().toURL();
  } catch (MalformedURLException e) {
   throw new FileNotFoundException("Mailformed URL while finding the "
     + "web resource dir:" + e.getMessage());
  }
 } else {
  resourceUrl =
    getClass().getClassLoader().getResource("webapps/" + appName);
  if (resourceUrl == null) {
   throw new FileNotFoundException("webapps/" + appName +
     " not found in CLASSPATH");
  }
 }
 String urlString = resourceUrl.toString();
 return urlString.substring(0, urlString.lastIndexOf('/'));
}

代码示例来源:origin: spring-projects/spring-security

private static URL toURL(String url) {
  try {
    return new URL(url);
  } catch (MalformedURLException ex) {
    throw new IllegalArgumentException("Invalid JWK Set URL \"" + url + "\" : " + ex.getMessage(), ex);
  }
}

代码示例来源:origin: geotools/geotools

private URL calculateImageUrl() {
  if (typ == ImportTyp.DIR) {
    try {
      return imageFiles[currentPos - 1].toURI().toURL();
    } catch (MalformedURLException e1) {
    }
  }
  URL startUrl = null;
  if (typ == ImportTyp.SHAPE) startUrl = shapeFileUrl;
  if (typ == ImportTyp.CSV) startUrl = csvFileURL;
  String path = startUrl.getPath();
  int index = path.lastIndexOf('/');
  String imagePath = null;
  if (index == -1) {
    imagePath = currentLocation;
  } else {
    imagePath = path.substring(0, index + 1) + currentLocation;
  }
  try {
    return new URL(
        startUrl.getProtocol(), startUrl.getHost(), startUrl.getPort(), imagePath);
  } catch (MalformedURLException e) {
    logError(e, e.getMessage());
    return null;
  }
}

代码示例来源:origin: Dreampie/Resty

/**
  * 扫描文件
  *
  * @param baseDir
  * @return
  */
 protected Enumeration<URL> urlSolve(String baseDir) {
  if (isAbsolutePath) {
   try {
    if (!baseDir.contains("/") && baseDir.contains(".")) {
     baseDir = baseDir.replaceAll("\\.", "/");
    }
    File file = new File(baseDir);
    return Collections.enumeration(Lister.<URL>of(file.toURI().toURL()));
   } catch (MalformedURLException e) {
    logger.error(e.getMessage(), e);
   }
  } else {
   super.urlSolve(baseDir);
  }
  return null;
 }
}

代码示例来源:origin: oracle/helidon

/**
 * Maps {@code stringValue} to {@code URL}.
 *
 * @param stringValue source value as a {@code String}
 * @return mapped {@code stringValue} to {@code URL}
 */
public static URL toUrl(String stringValue) {
  try {
    return new URL(stringValue);
  } catch (MalformedURLException e) {
    throw new IllegalArgumentException(e.getMessage(), e);
  }
}

代码示例来源:origin: apache/nifi

protected void logRequest(ComponentLog logger, URI endpoint, GenericApiGatewayRequest request) {
  try {
    logger.debug("\nRequest to remote service:\n\t{}\t{}\t\n{}",
      new Object[]{endpoint.toURL().toExternalForm(), request.getHttpMethod(), getLogString(request.getHeaders())});
  } catch (MalformedURLException e) {
    logger.debug(e.getMessage());
  }
}

代码示例来源:origin: spring-projects/spring-security-oauth

/**
 * Creates a new instance using the provided URLs as the location for the JWK Sets.
 *
 * @param jwkSetUrls the JWK Set URLs
 */
JwkDefinitionSource(List<String> jwkSetUrls) {
  this.jwkSetUrls = new ArrayList<URL>();
  for(String jwkSetUrl : jwkSetUrls) {
    try {
      this.jwkSetUrls.add(new URL(jwkSetUrl));
    } catch (MalformedURLException ex) {
      throw new IllegalArgumentException("Invalid JWK Set URL: " + ex.getMessage(), ex);
    }
  }
}

代码示例来源:origin: 4thline/cling

} else {
  try {
    URL testURI = getUri().toURL();
    if (testURI == null)
      throw new MalformedURLException();
        getClass(),
        "uri",
        "URL must be valid: " + ex.getMessage())
        );
  } catch (IllegalArgumentException ex) {

代码示例来源:origin: cloudfoundry/uaa

private static URI validateIssuer(String issuer) throws URISyntaxException {
  try {
    new URL(issuer);
  } catch (MalformedURLException x) {
    throw new URISyntaxException(issuer, x.getMessage());
  }
  return new URI(issuer);
}

代码示例来源:origin: mpetazzoni/ttorrent

private URL encodeAnnounceToURL(AnnounceRequestMessage.RequestEvent event, AnnounceableInformation torrentInfo, Peer peer) throws AnnounceException {
 URL result;
 try {
  HTTPAnnounceRequestMessage request = this.buildAnnounceRequest(event, torrentInfo, peer);
  result = request.buildAnnounceURL(this.tracker.toURL());
 } catch (MalformedURLException mue) {
  throw new AnnounceException("Invalid announce URL (" +
      mue.getMessage() + ")", mue);
 } catch (MessageValidationException mve) {
  throw new AnnounceException("Announce request creation violated " +
      "expected protocol (" + mve.getMessage() + ")", mve);
 } catch (IOException ioe) {
  throw new AnnounceException("Error building announce request (" +
      ioe.getMessage() + ")", ioe);
 }
 return result;
}

代码示例来源:origin: stagemonitor/stagemonitor

@Override
public URL convert(String s) throws IllegalArgumentException {
  try {
    return new URL(StringUtils.removeTrailingSlash(s));
  } catch (MalformedURLException e) {
    throw new IllegalArgumentException(e.getMessage());
  }
}

代码示例来源:origin: apache/nifi

protected void logResponse(ComponentLog logger, GenericApiGatewayResponse response) {
  try {
    logger.debug("\nResponse from remote service:\n\t{}\n{}",
        new Object[]{response.getHttpResponse().getHttpRequest().getURI().toURL().toExternalForm(), getLogString(response.getHttpResponse().getHeaders())});
  } catch (MalformedURLException e) {
    logger.debug(e.getMessage());
  }
}

相关文章