All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.virjar.ratel.api.SimpleHttpInvoker Maven / Gradle / Ivy

Go to download

ratel api,used for developer on ratel system,an extension for xposed framewrok,ratel api compatable with original xposed framework

There is a newer version: 1.3.6
Show newest version
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;
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy