Sunday, April 20, 2014

An exception: java.io.IOException: Malformed ipv6


Input parameters as: 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;
}

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

But I use the browser emulator enter the site is normally accessible.
This is what causes it?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Halo, day, nobody back.
Reply:
http://stackoverflow.com/questions / 6811482/use-url-on-android-throws-ioexception-malformed-ipv6-address


Reply:
reference to the second floor guoyoulei520 reply:
http://stackoverflow.com/questions/6811482/use-url-on-android-throws-ioexception-malformed-ipv6-address < / blockquote>

Thank
Indeed 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. .

No comments:

Post a Comment