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

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

本文整理了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

  1. private File toFile(final URL url) throws MalformedURLException {
  2. // only correct way to convert the URL to a File object, also see issue #16
  3. // Do not use URLDecoder
  4. try {
  5. return new File(url.toURI());
  6. } catch (URISyntaxException ex) {
  7. throw new MalformedURLException(ex.getMessage());
  8. } catch (IllegalArgumentException ex) {
  9. try {
  10. return new File(URLDecoder.decode(url.getFile(), "UTF-8"));
  11. } catch (Exception ex2) {
  12. throw new MalformedURLException(ex.getMessage());
  13. }
  14. }
  15. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Create a new {@code UrlResource} based on a URI specification.
  3. * <p>The given parts will automatically get encoded if necessary.
  4. * @param protocol the URL protocol to use (e.g. "jar" or "file" - without colon);
  5. * also known as "scheme"
  6. * @param location the location (e.g. the file path within that protocol);
  7. * also known as "scheme-specific part"
  8. * @param fragment the fragment within that location (e.g. anchor on an HTML page,
  9. * as following after a "#" separator)
  10. * @throws MalformedURLException if the given URL specification is not valid
  11. * @see java.net.URI#URI(String, String, String)
  12. */
  13. public UrlResource(String protocol, String location, @Nullable String fragment) throws MalformedURLException {
  14. try {
  15. this.uri = new URI(protocol, location, fragment);
  16. this.url = this.uri.toURL();
  17. this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString());
  18. }
  19. catch (URISyntaxException ex) {
  20. MalformedURLException exToThrow = new MalformedURLException(ex.getMessage());
  21. exToThrow.initCause(ex);
  22. throw exToThrow;
  23. }
  24. }

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

  1. @Override
  2. public String getGID(URL url) throws MalformedURLException {
  3. Pattern p = Pattern.compile("^https://clips\\.twitch\\.tv/(.*)$");
  4. Matcher m = p.matcher(url.toExternalForm());
  5. if (m.matches()) {
  6. return m.group(m.groupCount());
  7. }
  8. throw new MalformedURLException(
  9. "Expected Twitch.tv format:"
  10. + "https://clips.twitch.tv/####"
  11. + " Got: " + url);
  12. }

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

  1. public static InetSocketAddress getCliPort ( String jenkinsUrl ) throws MalformedURLException, IOException {
  2. URL u = new URL(jenkinsUrl);
  3. URLConnection conn = u.openConnection();
  4. if ( ! ( conn instanceof HttpURLConnection ) ) {
  5. System.err.println("Not a HTTP URL");
  6. throw new MalformedURLException();
  7. }
  8. HttpURLConnection hc = (HttpURLConnection) conn;
  9. if ( hc.getResponseCode() >= 400 ) {
  10. System.err.println("* Error connection to jenkins HTTP " + u);
  11. }
  12. int clip = Integer.parseInt(hc.getHeaderField("X-Jenkins-CLI-Port"));
  13. return new InetSocketAddress(u.getHost(), clip);
  14. }

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

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

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

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

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

  1. /**
  2. * Returns a new {@code HttpUrl} representing {@code url} if it is a well-formed HTTP or HTTPS
  3. * URL, or throws an exception if it isn't.
  4. *
  5. * @throws MalformedURLException if there was a non-host related URL issue
  6. * @throws UnknownHostException if the host was invalid
  7. */
  8. static HttpUrl getChecked(String url) throws MalformedURLException, UnknownHostException {
  9. Builder builder = new Builder();
  10. Builder.ParseResult result = builder.parse(null, url);
  11. switch (result) {
  12. case SUCCESS:
  13. return builder.build();
  14. case INVALID_HOST:
  15. throw new UnknownHostException("Invalid host: " + url);
  16. case UNSUPPORTED_SCHEME:
  17. case MISSING_SCHEME:
  18. case INVALID_PORT:
  19. default:
  20. throw new MalformedURLException("Invalid URL: " + result + " for " + url);
  21. }
  22. }

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

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

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

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

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

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

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

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

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

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

相关文章