I do a post request for debugging the application, in response I get bytearray how to display it at least somewhere? If I try to display it in a textview, then I get a crash.
String myURL = "http://s92640jz.bget.ru/register.php"; String params = "login=user123&open_key=rgh24sfs3efs234dir&key_size=4096"; byte[] data = null; InputStream is = null; try { URL url = new URL(myURL); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Content-Length", "" + Integer.toString(params.getBytes().length)); OutputStream os = conn.getOutputStream(); data = params.getBytes("UTF-8"); os.write(data); data = null; conn.connect(); int responseCode= conn.getResponseCode(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); is = conn.getInputStream(); byte[] buffer = new byte[1024]; // Такого вот размера буфер // Далее, например, вот так читаем ответ int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { baos.write(buffer, 0, bytesRead); } data = baos.toByteArray(); } catch (Exception e) { } finally { try { if (is != null) is.close(); } catch (Exception ex) {} }