得到java异常:java.net.MalformedURLException:没有协议 [英] getting java exception: java.net.MalformedURLException: no protocol

查看:292
本文介绍了得到java异常:java.net.MalformedURLException:没有协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在调用以下代码行:

I am currently calling the following line of code:

java.net.URL connection_url = new java.net.URL("http://<ip address>:<port>/path");

我执行时会得到上面的异常。关于为什么会发生这种情况的任何想法?

and I get the exception above when it executes. Any ideas as to why this is happening?

推荐答案

你的代码对我来说非常合适:

Your code works perfectly fine for me:

public static void main(String[] args) {
    try {
        java.net.URL connection_url = new java.net.URL("http://:/path");
        System.out.println("Instantiated new URL: " + connection_url);
    }
    catch (MalformedURLException e) {
        e.printStackTrace();
    }
}




实例化的新网址: http://:/ path

当然你有正确的代码行吗?

Sure you have the right line of code?

这篇关于得到java异常:java.net.MalformedURLException:没有协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆