Guest User

Untitled

a guest
Mar 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. public String call(String url) {
  2. Log.d("Lectura de CADENA ", "Iniciar leyendo");
  3. int BUFFER_SIZE = 2000;
  4. InputStream in = null;
  5. try {
  6. Log.d("Lectura de CADENA ", "antes del OpenHttpConnection");
  7. in = OpenHttpConnection(url);
  8. Log.d("Lectura de CADENA ", "despues del OpenHttpConnection");
  9. } catch (IOException e) {
  10. Log.e("ERROR: ", e.getMessage() + ": MENSAJE: ERROR AL CREAR CONEXION OpenHttpConnection ");
  11. e.printStackTrace();
  12. return "";
  13. }
  14. Log.d("Lectura de CADENA ", "antes del InputStreamReader");
  15. InputStreamReader isr = new InputStreamReader(in);
  16. Log.d("Lectura de CADENA ", "antes del InputStreamReader");
  17. int charRead;
  18. String str = "";
  19. char[] inputBuffer = new char[BUFFER_SIZE];
  20. try {
  21. Log.d("Lectura de CADENA ", "antes del while");
  22. while ((charRead = isr.read(inputBuffer)) > 0) {
  23. Log.d("Lectura de CADENA ", "dentro del while");
  24. Log.d("Lectura de CADENA ", "Leyendo el inputBuffer ");
  25. String readString = String.copyValueOf(inputBuffer, 0, charRead);
  26. Log.d("Lectura de CADENA ", "readString = " + readString);
  27. str += readString;
  28. Log.d("Lectura de CADENA ", "CADENA = " + str);
  29. inputBuffer = new char[BUFFER_SIZE];
  30. }
  31. in.close();
  32. Log.d("Lectura de CADENA ", "despues del while");
  33. } catch (IOException e) {
  34. Log.e("ERROR: ", e.getMessage() + ": MENSAJE: ERROR AL LLAMAR LA URL ");
  35. e.printStackTrace();
  36. return "";
  37. }
  38. return str;
  39. }
Add Comment
Please, Sign In to add comment