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;
}
returns an exception :
09-16 09:32:58.892: I / System.out (416): java.io.IOException: Malformed ipv6 address: [192.168.1.173:8080]
but I use a browser on the simulator is able to properly enter the site visit .
This is what causes it ?
------ Solution ---------------------------------------- ----
http: / / stackoverflow.com/questions/6811482/use-url-on-android-throws-ioexception-malformed-ipv6-address
------ eference ------------------------------------ ---
halo, day, nobody back .
------ eference --------------------------------------- < br>
Thank you
really is for this reason
Use
URL url = new URL ("http", "192.168.1.173", "8080", "/ Api / petinfo / petinfo? flag = adopt & json = [{"pettype": "100", "petname": "ge"}] ");
can be passed . .
没有评论:
发表评论