Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6054421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:09:02+00:00 2026-05-23T08:09:02+00:00

What I’m trying to do is get some json results back from a URL

  • 0

What I’m trying to do is get some json results back from a URL using a Bufferedreader which uses a inputstreamreader. I read each line and for each JSONObject i get properties and do awesome things with them later.

Anyway, on Android 2.2 the code works fine but when i test on a 2.3 device (emulated, stock, or custom rom alike) i get this exception:

06-22 15:33:13.958: ERROR/App(416): IOException
06-22 15:33:13.958: ERROR/App(416): java.io.IOException: CRC mismatch
06-22 15:33:13.958: ERROR/App(416):     at java.util.zip.GZIPInputStream.verifyCrc(GZIPInputStream.java:201)
06-22 15:33:13.958: ERROR/App(416):     at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:184)
06-22 15:33:13.958: ERROR/App(416):     at java.io.InputStreamReader.read(InputStreamReader.java:255)
06-22 15:33:13.958: ERROR/App(416):     at java.io.BufferedReader.fillBuf(BufferedReader.java:128)
06-22 15:33:13.958: ERROR/App(416):     at java.io.BufferedReader.readLine(BufferedReader.java:357)
06-22 15:33:13.958: ERROR/App(416):     at ca.bnotions.App.Places.fetchData(Places.java:57)
06-22 15:33:13.958: ERROR/App(416):     at ca.bnotions.App.Places.onCreate(Places.java:40)
06-22 15:33:13.958: ERROR/App(416):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-22 15:33:13.958: ERROR/App(416):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-22 15:33:13.958: ERROR/App(416):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-22 15:33:13.958: ERROR/App(416):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-22 15:33:13.958: ERROR/App(416):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-22 15:33:13.958: ERROR/App(416):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-22 15:33:13.958: ERROR/App(416):     at android.os.Looper.loop(Looper.java:123)
06-22 15:33:13.958: ERROR/App(416):     at android.app.ActivityThread.main(ActivityThread.java:3683)
06-22 15:33:13.958: ERROR/App(416):     at java.lang.reflect.Method.invokeNative(Native Method)
06-22 15:33:13.958: ERROR/App(416):     at java.lang.reflect.Method.invoke(Method.java:507)
06-22 15:33:13.958: ERROR/App(416):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-22 15:33:13.958: ERROR/App(416):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-22 15:33:13.958: ERROR/App(416):     at dalvik.system.NativeStart.main(Native Method)

Here is the code I’m using:

public ArrayList<String> fetchData()
    {
        list_items = new ArrayList<String>();
        try {
            URL places_data = new URL("http://myurl.com");
            URLConnection tc = places_data.openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(tc.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                JSONArray ja = new JSONArray(line);

                for (int i = 0; i < ja.length(); i++) {
                    JSONObject jo = (JSONObject) ja.get(i);
                    list_items.add(jo.getString("name"));
                }
            }
        } catch (MalformedURLException e) {
            Log.e("MyApp","MalformedURLException",e);
        } catch (IOException e) {
            Log.e("MyApp","IOException",e);
        } catch (JSONException e) {
            Log.e("MyApp","JSONException",e);
        }

        return list_items;
    }

Any insight would be greatly appreciated.

Thanks,

Marcus

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:09:03+00:00Added an answer on May 23, 2026 at 8:09 am

    I don’t have time to research this to understand why it doesn’t work and why you are getting the error. But I do have time to show you how I do it which works great.

    Download the Apache Mime and Commons HttpClient Jar libraries and add them to your project’s Java Build Path.

    HttpClient client = new DefaultHttpClient();
    HttpGet request = new HttpGet();
    request.setURI(new URI("http://www.codinggreenrobots.com"));
    
    HttpResponse response = client.execute(request);
    
    BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    StringBuffer sb = new StringBuffer("");
    String line = "";
    while ((line = in.readLine()) != null) {
        sb.append(line + "\n";
    }
    in.close();
    str_response = sb.toString();
    

    Now that you have parsed the response, just turn it in a JSONObject.

    JSONObject event_object = new JSONObject(str_response);
    

    I hope that works for you as well as it works for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.