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

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

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

MalformedURLException.<init>介绍

[英]Constructs a new instance.
[中]构造一个新实例。

代码示例

代码示例来源:origin: Atmosphere/atmosphere

private File toFile(final URL url) throws MalformedURLException {
  // only correct way to convert the URL to a File object, also see issue #16
  // Do not use URLDecoder
  try {
    return new File(url.toURI());
  } catch (URISyntaxException ex) {
    throw new MalformedURLException(ex.getMessage());
  } catch (IllegalArgumentException ex) {
    try {
      return new File(URLDecoder.decode(url.getFile(), "UTF-8"));
    } catch (Exception ex2) {
      throw new MalformedURLException(ex.getMessage());
    }
  }
}

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

private MySqlJdbcUrl(String url) throws MalformedURLException, URISyntaxException {
 if (!url.startsWith(PREFIX)) {
 throw new MalformedURLException();
 }
 builder = new URIBuilder(url.substring(PREFIX.length()));
}

代码示例来源:origin: RipMeApp/ripme

@Override
public String getGID(URL url) throws MalformedURLException {
  Matcher m = p1.matcher(url.toExternalForm());
  if (m.matches()) {
    return m.group(1);
  }
  throw new MalformedURLException(
      "Expected hqporner URL format: " + "hentaidude.com/VIDEO - got " + url + " instead");
}

代码示例来源:origin: RipMeApp/ripme

@Override
public String getGID(URL url) throws MalformedURLException {
  Pattern p = Pattern.compile("^https?://[wm.]*shesfreaky\\.com/gallery/([a-zA-Z0-9\\-_]+).*$");
  Matcher m = p.matcher(url.toExternalForm());
  if (m.matches()) {
    return m.group(1);
  }
  throw new MalformedURLException("Expected shesfreaky.com URL format: "
      + "shesfreaky.com/gallery/... - got " + url + "instead");
}

代码示例来源:origin: RipMeApp/ripme

@Override
public String getGID(URL url) throws MalformedURLException {
  Pattern p = Pattern.compile("https?://gfycatporntube.com/([a-zA-Z1-9_-]*)/?$");
  Matcher m = p.matcher(url.toExternalForm());
  if (m.matches()) {
    return m.group(1);
  }
  throw new MalformedURLException("Expected gfycatporntube URL format: " +
      "gfycatporntube.com/NAME - got " + url + " instead");
}

代码示例来源:origin: RipMeApp/ripme

@Override
public String getGID(URL url) throws MalformedURLException {
  Pattern p = Pattern.compile("https?://www.picstatio.com/([a-zA-Z1-9_-]*)/?$");
  Matcher m = p.matcher(url.toExternalForm());
  if (m.matches()) {
    return m.group(1);
  }
  throw new MalformedURLException("Expected picstatio URL format: " +
      "www.picstatio.com//ID - got " + url + " instead");
}

代码示例来源:origin: RipMeApp/ripme

@Override
public String getGID(URL url) throws MalformedURLException {
  Pattern p = Pattern.compile("^https?://[wm.]*youporn\\.com/watch/([0-9]+).*$");
  Matcher m = p.matcher(url.toExternalForm());
  if (m.matches()) {
    return m.group(1);
  }
  throw new MalformedURLException(
      "Expected youporn format:"
          + "youporn.com/watch/####"
          + " Got: " + url);
}

代码示例来源:origin: RipMeApp/ripme

@Override
public String getGID(URL url) throws MalformedURLException {
  Pattern p = Pattern.compile("^http://.*tubex6\\.com/(.*)/$");
  Matcher m = p.matcher(url.toExternalForm());
  if (m.matches()) {
    return m.group(1);
  }
  throw new MalformedURLException("Expected tubex6.com URL format: " +
      "tubex6.com/NAME - got " + url + " instead");
}

代码示例来源:origin: RipMeApp/ripme

@Override
public String getGID(URL url) throws MalformedURLException {
  Pattern p = Pattern.compile("https?://www\\.modelmayhem\\.com/portfolio/(\\d+)/viewall");
  Matcher m = p.matcher(url.toExternalForm());
  if (m.matches()) {
    return m.group(1);
  }
  throw new MalformedURLException("Expected modelmayhem URL format: " +
      "modelmayhem.com/portfolio/ID/viewall - got " + url + " instead");
}

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

/**
 * Create a new {@code UrlResource} based on a URI specification.
 * <p>The given parts will automatically get encoded if necessary.
 * @param protocol the URL protocol to use (e.g. "jar" or "file" - without colon);
 * also known as "scheme"
 * @param location the location (e.g. the file path within that protocol);
 * also known as "scheme-specific part"
 * @param fragment the fragment within that location (e.g. anchor on an HTML page,
 * as following after a "#" separator)
 * @throws MalformedURLException if the given URL specification is not valid
 * @see java.net.URI#URI(String, String, String)
 */
public UrlResource(String protocol, String location, @Nullable String fragment) throws MalformedURLException  {
  try {
    this.uri = new URI(protocol, location, fragment);
    this.url = this.uri.toURL();
    this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString());
  }
  catch (URISyntaxException ex) {
    MalformedURLException exToThrow = new MalformedURLException(ex.getMessage());
    exToThrow.initCause(ex);
    throw exToThrow;
  }
}

代码示例来源:origin: RipMeApp/ripme

@Override
public String getGID(URL url) throws MalformedURLException {
  Pattern p = Pattern.compile("^https://clips\\.twitch\\.tv/(.*)$");
  Matcher m = p.matcher(url.toExternalForm());
  if (m.matches()) {
    return m.group(m.groupCount());
  }
  throw new MalformedURLException(
      "Expected Twitch.tv format:"
          + "https://clips.twitch.tv/####"
          + " Got: " + url);
}

代码示例来源:origin: frohoff/ysoserial

public static InetSocketAddress getCliPort ( String jenkinsUrl ) throws MalformedURLException, IOException {
  URL u = new URL(jenkinsUrl);

  URLConnection conn = u.openConnection();
  if ( ! ( conn instanceof HttpURLConnection ) ) {
    System.err.println("Not a HTTP URL");
    throw new MalformedURLException();
  }

  HttpURLConnection hc = (HttpURLConnection) conn;
  if ( hc.getResponseCode() >= 400 ) {
    System.err.println("* Error connection to jenkins HTTP " + u);
  }
  int clip = Integer.parseInt(hc.getHeaderField("X-Jenkins-CLI-Port"));

  return new InetSocketAddress(u.getHost(), clip);
}

代码示例来源:origin: RipMeApp/ripme

@Override
public String getGID(URL url) throws MalformedURLException {
  String capID = getChapterID(url.toExternalForm());
  if (capID != null) {
    return capID;
  }
  throw new MalformedURLException("Unable to get chapter ID from" + url);
}

代码示例来源:origin: jenkinsci/jenkins

throw new MalformedURLException("The specified file path " + fileName + " is not allowed due to security reasons");

代码示例来源:origin: prestodb/presto

/**
 * Returns a new {@code HttpUrl} representing {@code url} if it is a well-formed HTTP or HTTPS
 * URL, or throws an exception if it isn't.
 *
 * @throws MalformedURLException if there was a non-host related URL issue
 * @throws UnknownHostException if the host was invalid
 */
static HttpUrl getChecked(String url) throws MalformedURLException, UnknownHostException {
 Builder builder = new Builder();
 Builder.ParseResult result = builder.parse(null, url);
 switch (result) {
  case SUCCESS:
   return builder.build();
  case INVALID_HOST:
   throw new UnknownHostException("Invalid host: " + url);
  case UNSUPPORTED_SCHEME:
  case MISSING_SCHEME:
  case INVALID_PORT:
  default:
   throw new MalformedURLException("Invalid URL: " + result + " for " + url);
 }
}

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

@Override
public final MalformedURLException invalidURIEncoding(final String encoding) {
  final MalformedURLException result = new MalformedURLException(String.format(getLoggingLocale(), invalidURIEncoding$str(), encoding));
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String failedToLookupJSSEDomain = "WFLYIIOP0051: Error configuring domain socket factory: failed to lookup JSSE security domain";

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

@Override
public final MalformedURLException invalidURL(final String protocol, final String url) {
  final MalformedURLException result = new MalformedURLException(String.format(getLoggingLocale(), invalidURL$str(), protocol, url));
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String problemInvokingPortableRemoteObjectToStub = "WFLYIIOP0041: Problem with PortableRemoteObject.toStub(); object not exported or stub not found";

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

@Override
public final MalformedURLException invalidIIOPURLVersion(final String version) {
  final MalformedURLException result = new MalformedURLException(String.format(getLoggingLocale(), invalidIIOPURLVersion$str(), version));
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String unavailableRMIPackages = "WFLYIIOP0048: javax.rmi packages not available";

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

@Override
public final MalformedURLException unavailableISOLatin1Decoder() {
  final MalformedURLException result = new MalformedURLException(String.format(getLoggingLocale(), unavailableISOLatin1Decoder$str()));
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String invalidURIEncoding = "WFLYIIOP0050: Invalid URI encoding: %s";

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

String protocol = url.getProtocol();
if (protocol != null && !"rmi".equals(protocol)) {
  throw new MalformedURLException("Invalid URL scheme '" + protocol + "'");

相关文章