Guest User

Untitled

a guest
Jul 21st, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. HttpConnection h = new HttpConnection();
  2. InputStream input = h.openInputStream();
  3. int len = (int) h.httpConn.getLength();
  4.  
  5. StringBuffer raw = new StringBuffer();
  6.  
  7. if(len > 0)
  8. {
  9. byte[] data = new byte[len];
  10. while( -1 != (len = input.read(data)))
  11. {
  12. raw.append(new String(data, 0, len));
  13. }
  14. }
  15.  
  16. response = raw.toString();
  17. input.close();
  18. h.httpConn.close();
  19. //System.out.println("Response -----> " + response);
  20.  
  21. return response;
  22.  
  23. public String getContents(InputStream stream) {
  24. String contents = null;
  25. try{
  26. contents = new String(IOUtilities.streamToBytes(stream), "UTF-8");
  27. }
  28. catch(Exception e) {
  29. //encoding error
  30. }
  31. return contents;
  32. }
Add Comment
Please, Sign In to add comment