this works:
            String buffer = null;
            HttpResponse response = client.execute(get);
            entity = response.getEntity();
            status = response.getStatusLine().getStatusCode();
            InputStream in = entity.getContent();
            for (int i = in.read(); i != -1; i = in.read()) {
                buffer += (char) i;
            }
            in.close();
            if (entity != null) {
                entity.consumeContent();
            }

or this
            HttpResponse response = client.execute(get);
            entity = response.getEntity();
            status = response.getStatusLine().getStatusCode();
            InputStream in = entity.getContent();
            Document document = getDocument(in);
            in.close();
            if (entity != null) {
                entity.consumeContent();
            }

Christine



On Oct 26, 10:05 am, JamesB <[EMAIL PROTECTED]> wrote:
> I have been trying to get the content of a web page which just has
> only a string on it.  I want to put the entire content of the page
> into a variable so I can use it.  I found some code in another thread
> and tried to use it, but it isnt working for me.
>
> public String getPrice(String symbol) {
>         DefaultHttpClient client = new DefaultHttpClient();
>         HttpGet get = null;
>         HttpResponse resp = null;
>
>         get = new HttpGet("http://oxavi.com/price.php";);
>
>         try {
>                         resp = client.execute(get);
>                 } catch (ClientProtocolException e) {
>                         return "resp ParseException e";
>                 } catch (IOException e) {
>                         return "resp IOException e";
>                 }
>
>         HttpEntity entity = resp.getEntity();
>
>                 try {
>                         String price = EntityUtils.toString(entity);
>                         return price;
>                 } catch (ParseException e) {
>                         return "EntityUtils ParseException e";
>                 } catch (IOException e) {
>                         return "EntityUtils IOException e";
>                 }
>         }
>
> When I run it the function returns 'resp IOException'.  I want it to
> return '234.52', the entire content of the page.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to