com.virjar.ratel.api.SimpleHttpInvoker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ratel-api Show documentation
Show all versions of ratel-api Show documentation
ratel api,used for developer on ratel system,an extension for xposed framewrok,ratel api compatable with original xposed framework
package com.virjar.ratel.api;
import android.util.Log;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import external.org.apache.commons.io.IOUtils;
public class SimpleHttpInvoker {
public static String get(String url) {
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("GET");
connection.connect();
int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
connection.disconnect();
return null;
}
try (InputStream inputStream = connection.getInputStream()) {
return IOUtils.toString(inputStream, StandardCharsets.UTF_8);
} finally {
connection.disconnect();
}
} catch (Exception e) {
Log.e(RatelToolKit.TAG, "error for url:" + url, e);
return null;
}
}
}