Hey I am new to Java and developing apps for android. I tried without success to convert a InputStream into a String.
public String Request(String url) { InputStream content = null; try { HttpGet httpGet = new HttpGet(url); HttpClient httpclient = new DefaultHttpClient(); // Execute HTTP Get Request HttpResponse response = httpclient.execute(httpGet); content = response.getEntity().getContent(); } catch (Exception e) { //handle the exception ! } try { return convert(content); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return e.getMessage(); } } public String convert(InputStream is) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line); } is.close(); return sb.toString(); } If i use this Code my App crashes. The Website only contains the word "Test", nothing more. I really hope you are able to help me. Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en