如何解决java.net.MalformedURLException? [英] How to resolve java.net.MalformedURLException?

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

问题描述

我收到此错误:

  java.net.MalformedURLException:协议没有找到[java.lang.StringBuilder中]
 

在下面一行是越来越执行:

  URL =新的URL(urlString.toString());
 

urlString存储以下值:

<$p$p><$c$c>http://maps.google.com/maps?f=d&hl=en&saddr=25.04202,121.534761&daddr=25.05202,121.554761&ie=UTF8&0&om=0&output=kml

是什么原因导致这种异常?

解决方案

有机会,你更改后没有清洁

  URL =新的URL(urlString);
 

  URL =新的URL(urlString.toString());
 

您应该登录传递到URL的构造函数的参数的值。 这是不是你认为它应该是。

urlString将在java.lang.StringBuilder中的形式打印值@ 如果你尝试建立一个url出来,如此抛出异常。

但使用到的字符串将打印在StringBuilder的内置内容字符串的值。

I am getting this error:

java.net.MalformedURLException: Protocol not found[java.lang.StringBuilder] 

When the following line is getting executed:

url = new URL(urlString.toString());

urlString stores the following value:

http://maps.google.com/maps?f=d&hl=en&saddr=25.04202,121.534761&daddr=25.05202,121.554761&ie=UTF8&0&om=0&output=kml

What causes this Exception?

解决方案

Chances are that you didn't clean after changing from

url = new URL( urlString );

to

url = new URL(urlString.toString());

You should log the value of the parameter passed to the constructor of URL. It's not what you think it should be.

urlString would print a value in the form of java.lang.StringBuilder@ thus throwing the exception if you try to build a url out of that.

But using to String will print the value of the content string built by the stringbuilder.

这篇关于如何解决java.net.MalformedURLException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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