当前位置: 代码迷 >> Android >> 出现错误:java.io.IOException: Malformed ipv6
  详细解决方案

出现错误:java.io.IOException: Malformed ipv6

热度:460   发布时间:2016-04-28 08:06:18.0
出现异常:java.io.IOException: Malformed ipv6
输入的参数为:http://192.168.1.173:8080/Api/petinfo/petinfo?flag=adopt&json=[{"pettype":"100","petname":"ge"}]


public static InputStream getInputStreamFromUrl(String urlstr){
try {
InputStream is = null;
HttpURLConnection conn = null;
System.out.println("urlstr:"+urlstr);
URL url = new URL(urlstr);
conn = (HttpURLConnection) url.openConnection();
if (conn.getResponseCode() == 200) {
is = conn.getInputStream();
return is;
}
} catch (Exception e) {
System.out.println(e.toString());
}
return null;
}

返回异常:
09-16 09:32:58.892: I/System.out(416): java.io.IOException: Malformed ipv6 address: [192.168.1.173:8080]

但是我用模拟器上的浏览器输入该网站是能正常访问的。
这是什么原因呢?

------解决方案--------------------
http://stackoverflow.com/questions/6811482/use-url-on-android-throws-ioexception-malformed-ipv6-address

  相关解决方案