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

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

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

MalformedURLException.getMessage介绍

暂无

代码示例

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

  1. public java.net.URL toJavaURL() {
  2. try {
  3. return new java.net.URL(toString());
  4. } catch (MalformedURLException e) {
  5. throw new IllegalStateException(e.getMessage(), e);
  6. }
  7. }

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

  1. /**
  2. * @param file file to handle
  3. * @param depth recursion depth
  4. * @param results collection
  5. * {@inheritDoc}
  6. */
  7. protected void handleFile(File file, int depth, Collection results) {
  8. try {
  9. // Looks Strange, but is actually recommended over just .URL()
  10. results.add(file.toURI().toURL());
  11. } catch (MalformedURLException e) {
  12. log.debug("MalformedURLException" + e.getMessage());
  13. }
  14. }

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

  1. private String getResourceUrlString(String resource) {
  2. URL url = null;
  3. try {
  4. if (resource.startsWith("http") || resource.startsWith("file")) {
  5. url = new URL(resource);
  6. }
  7. else {
  8. url = new File(resource).toURI().toURL();
  9. }
  10. }
  11. catch (MalformedURLException ex) {
  12. logger.log(Level.WARNING, "Failed to determine URL of " + resource + ". Reason: " + ex.getMessage());
  13. logger.log(Level.FINER, "Details: ", ex);
  14. }
  15. return url != null ? url.toString() : null;
  16. }

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

  1. public java.net.URL toJavaURL() {
  2. try {
  3. return new java.net.URL(toString());
  4. } catch (MalformedURLException e) {
  5. throw new IllegalStateException(e.getMessage(), e);
  6. }
  7. }

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

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

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

  1. public void addJars(List<String> dirs) {
  2. for (String dir : dirs) {
  3. try {
  4. myloader.addJar(Paths.get(dir).toUri().toURL());
  5. } catch (MalformedURLException e) {
  6. logger.error(e.getMessage());
  7. }
  8. }
  9. }

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

  1. private URL toURL(String urlStr) {
  2. try {
  3. return new URL(urlStr);
  4. } catch (MalformedURLException ex) {
  5. throw new IllegalArgumentException("Unable to convert '" + urlStr + "' to URL: " + ex.getMessage(), ex);
  6. }
  7. }
  8. }

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

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

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

  1. /**
  2. * Get the pathname to the webapps files.
  3. * @param appName eg "secondary" or "datanode"
  4. * @return the pathname as a URL
  5. * @throws FileNotFoundException if 'webapps' directory cannot be found
  6. * on CLASSPATH or in the development location.
  7. */
  8. protected String getWebAppsPath(String appName) throws FileNotFoundException {
  9. URL resourceUrl = null;
  10. File webResourceDevLocation = new File("src/main/webapps", appName);
  11. if (webResourceDevLocation.exists()) {
  12. LOG.info("Web server is in development mode. Resources "
  13. + "will be read from the source tree.");
  14. try {
  15. resourceUrl = webResourceDevLocation.getParentFile().toURI().toURL();
  16. } catch (MalformedURLException e) {
  17. throw new FileNotFoundException("Mailformed URL while finding the "
  18. + "web resource dir:" + e.getMessage());
  19. }
  20. } else {
  21. resourceUrl =
  22. getClass().getClassLoader().getResource("webapps/" + appName);
  23. if (resourceUrl == null) {
  24. throw new FileNotFoundException("webapps/" + appName +
  25. " not found in CLASSPATH");
  26. }
  27. }
  28. String urlString = resourceUrl.toString();
  29. return urlString.substring(0, urlString.lastIndexOf('/'));
  30. }

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

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

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

  1. private URL calculateImageUrl() {
  2. if (typ == ImportTyp.DIR) {
  3. try {
  4. return imageFiles[currentPos - 1].toURI().toURL();
  5. } catch (MalformedURLException e1) {
  6. }
  7. }
  8. URL startUrl = null;
  9. if (typ == ImportTyp.SHAPE) startUrl = shapeFileUrl;
  10. if (typ == ImportTyp.CSV) startUrl = csvFileURL;
  11. String path = startUrl.getPath();
  12. int index = path.lastIndexOf('/');
  13. String imagePath = null;
  14. if (index == -1) {
  15. imagePath = currentLocation;
  16. } else {
  17. imagePath = path.substring(0, index + 1) + currentLocation;
  18. }
  19. try {
  20. return new URL(
  21. startUrl.getProtocol(), startUrl.getHost(), startUrl.getPort(), imagePath);
  22. } catch (MalformedURLException e) {
  23. logError(e, e.getMessage());
  24. return null;
  25. }
  26. }

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

  1. /**
  2. * 扫描文件
  3. *
  4. * @param baseDir
  5. * @return
  6. */
  7. protected Enumeration<URL> urlSolve(String baseDir) {
  8. if (isAbsolutePath) {
  9. try {
  10. if (!baseDir.contains("/") && baseDir.contains(".")) {
  11. baseDir = baseDir.replaceAll("\\.", "/");
  12. }
  13. File file = new File(baseDir);
  14. return Collections.enumeration(Lister.<URL>of(file.toURI().toURL()));
  15. } catch (MalformedURLException e) {
  16. logger.error(e.getMessage(), e);
  17. }
  18. } else {
  19. super.urlSolve(baseDir);
  20. }
  21. return null;
  22. }
  23. }

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

  1. /**
  2. * Maps {@code stringValue} to {@code URL}.
  3. *
  4. * @param stringValue source value as a {@code String}
  5. * @return mapped {@code stringValue} to {@code URL}
  6. */
  7. public static URL toUrl(String stringValue) {
  8. try {
  9. return new URL(stringValue);
  10. } catch (MalformedURLException e) {
  11. throw new IllegalArgumentException(e.getMessage(), e);
  12. }
  13. }

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

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

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

  1. /**
  2. * Creates a new instance using the provided URLs as the location for the JWK Sets.
  3. *
  4. * @param jwkSetUrls the JWK Set URLs
  5. */
  6. JwkDefinitionSource(List<String> jwkSetUrls) {
  7. this.jwkSetUrls = new ArrayList<URL>();
  8. for(String jwkSetUrl : jwkSetUrls) {
  9. try {
  10. this.jwkSetUrls.add(new URL(jwkSetUrl));
  11. } catch (MalformedURLException ex) {
  12. throw new IllegalArgumentException("Invalid JWK Set URL: " + ex.getMessage(), ex);
  13. }
  14. }
  15. }

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

  1. } else {
  2. try {
  3. URL testURI = getUri().toURL();
  4. if (testURI == null)
  5. throw new MalformedURLException();
  6. getClass(),
  7. "uri",
  8. "URL must be valid: " + ex.getMessage())
  9. );
  10. } catch (IllegalArgumentException ex) {

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

  1. private static URI validateIssuer(String issuer) throws URISyntaxException {
  2. try {
  3. new URL(issuer);
  4. } catch (MalformedURLException x) {
  5. throw new URISyntaxException(issuer, x.getMessage());
  6. }
  7. return new URI(issuer);
  8. }

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

  1. private URL encodeAnnounceToURL(AnnounceRequestMessage.RequestEvent event, AnnounceableInformation torrentInfo, Peer peer) throws AnnounceException {
  2. URL result;
  3. try {
  4. HTTPAnnounceRequestMessage request = this.buildAnnounceRequest(event, torrentInfo, peer);
  5. result = request.buildAnnounceURL(this.tracker.toURL());
  6. } catch (MalformedURLException mue) {
  7. throw new AnnounceException("Invalid announce URL (" +
  8. mue.getMessage() + ")", mue);
  9. } catch (MessageValidationException mve) {
  10. throw new AnnounceException("Announce request creation violated " +
  11. "expected protocol (" + mve.getMessage() + ")", mve);
  12. } catch (IOException ioe) {
  13. throw new AnnounceException("Error building announce request (" +
  14. ioe.getMessage() + ")", ioe);
  15. }
  16. return result;
  17. }

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

  1. @Override
  2. public URL convert(String s) throws IllegalArgumentException {
  3. try {
  4. return new URL(StringUtils.removeTrailingSlash(s));
  5. } catch (MalformedURLException e) {
  6. throw new IllegalArgumentException(e.getMessage());
  7. }
  8. }

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

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

相关文章