Solución:
Utilice Android Uri
clase. http://developer.android.com/reference/android/net/Uri.html
Uri uri = Uri.parse("https://graph.facebook.com/me/home?limit=25&since=1374196005");
String protocol = uri.getScheme();
String server = uri.getAuthority();
String path = uri.getPath();
Set<String> args = uri.getQueryParameterNames();
String limit = uri.getQueryParameter("limit");
Para Java puro, creo que este código debería funcionar:
import java.net.URL;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
public class UrlTest {
public static void main(String[] args) {
try {
String s = "https://graph.facebook.com/me/home?limit=25&since=1374196005";
URL url = new URL(s);
String query = url.getQuery();
Map<String, String> data = new HashMap<String, String>();
for (String q : query.split("&")) {
String[] qa = q.split("=");
String name = URLDecoder.decode(qa[0]);
String value = "";
if (qa.length == 2) {
value = URLDecoder.decode(qa[1]);
}
data.put(name, value);
}
System.out.println(data);
} catch (Exception e) {
e.printStackTrace();
}
}
}
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)