Back to project page face_rec_android.
The source code is released under:
GNU General Public License
If you think the Android project face_rec_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package in.amolgupta.helpingfaceless.utils; // w w w .j av a 2 s . c om import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import com.squareup.okhttp.OkHttpClient; public class RequestUtils { public static byte[] readFully(InputStream in) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; for (int count; (count = in.read(buffer)) != -1;) { out.write(buffer, 0, count); } return out.toByteArray(); } public static String get(URL url, OkHttpClient client) throws IOException { HttpURLConnection connection = client.open(url); InputStream in = null; try { // Read the response. in = connection.getInputStream(); byte[] response = readFully(in); return new String(response, "UTF-8"); } finally { if (in != null) in.close(); } } }