0

I am trying to read HTTP response using the HTTPUrlConnection in Android.

The getcontent() method of HTTPUrlConnection says it returns "Object" representing the content. What type of object is this? It's just saying "object" which I believe is the root object. What method can I use to extract the contents?

Also, Instead if I use getInputStream() of HTTPUrlConnection and start reading it's contents, will it give me the data staring right from the headers or from the content?

Thanks.

soupybionics
  • 4,200
  • 6
  • 31
  • 43

1 Answers1

0

With getInputStream() you will receive the whole page including headers and so on.

Exaple from: http://developer.android.com/reference/java/net/HttpURLConnection.html

  URL url = new URL("http://www.android.com/");   
  HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
 InputStream in = new BufferedInputStream(urlConnection.getInputStream());
 readStream(in);
finally {
 urlConnection.disconnect();
}
}

With getContent() you get an normal Java Object thats right. I think u can cast it to a String and so get it's content.

grahan
  • 2,148
  • 5
  • 29
  • 43