输入的参数为: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]但是我用模拟器上的浏览器输入该网站是能正常访问的。
这是什么原因呢?
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]但是我用模拟器上的浏览器输入该网站是能正常访问的。
这是什么原因呢?
解决方案 »
- 请问如何加载局部界面,我想用一个view来显示每个Activity的布局,怎么做?求大神给思路
- 高分求助,pc端c++截取android手机端屏幕问题!!希望各位大侠来帮帮我啊!!
- Gallery Adapter 更新的问题
- Android jpg exif信息
- Android图形界面的分辨率为什么和lcd的分辨率不一样
- android平板电脑上的开发是个什么情况?
- 安卓如何读写其他进程的内存
- android button 布局的问题
- 关于Android Studio安装问题
- bmob 安卓端可以连表查询吗? 感觉限制还是很多,,是自己没玩转吗
- android 菜单问题
- java.net.InetAddress.getByName 程序直接退出 ??
确实是这个原因
使用
URL url = new URL(“http”,"192.168.1.173", "8080", "/Api/petinfo/petinfo?flag=adopt&json=[{"pettype":"100","petname":"ge"}]");
就可以通过了。。