InputStreamReader isr = new InputStreamReader(conn.getInputStream()); BufferedReader br = new BufferedReader(isr); StringBuffer sb = new StringBuffer(); String line; while ((line = br.readLine()) != null) { sb.append(line); } br.close(); result = sb.toString(); System.out.println(result);
- Get an Input Stream from an existing object such as a connection object and pass it as the parameter in the constructor of the InputStreamReader
- Create a new BufferedReader object and pass the newly created InputStreamReader throught the constructor.
- Create a StringBuffer object for later use.
- Iterate through the BufferedReader, reading each line of data. Append the data into the StringBuffer object.
- When done close the BufferedReader object.
- Convert the StringBuffer to a string and print it.