String str1="http://10.0.2.2/moodle";
String str4="admin";
String str5="S12345s@";
try{
String getToken = str1 + "/login/token.php?username=" + str4 + "&password=" + str5 + "&service=moodle_mobile_app";
String inputLine = null;
URL url = new URL(getToken.toString());
System.out.println("Port----------->"+url.getPort());
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
while ((inputLine = in.readLine()) != null) {
System.out.println("test1"+inputLine);
}
in.close();
} catch(Exception e) {
System.out.println(e.toString());
}
}
when i try to get the token from localhost moodle course web and i got port number as -1. I got this error":"Invalid url or port. for above code please help me to fix this error.