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

  • Home
  • SEARCH
  • 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 9207733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:27:09+00:00 2026-06-18T00:27:09+00:00

In my app i am trying to retrieve the data from a fb graph

  • 0

In my app i am trying to retrieve the data from a fb graph api url as below

URL fbmsg = new URL("https://graph.facebook.com/"+FbPostId()+"?access_token="+TOKEN+"");
            URLConnection yc = fbmsg.openConnection();

            BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));

            String inputLine;

            String s = "";

            while ((inputLine = in.readLine()) != null)

            System.out.println(inputLine);
            //Log.d(TAG, "getPostId trace getFbPostId " + inputLine);   
            s = s + inputLine + "n";
            //Log.d(TAG, "getPostId trace getFbPostId " + s);   
            in.close();
            //System.out.println(s);

            JSONObject json = new JSONObject(inputLine);
            //JSONObject message = json.getJSONObject("message");
           String fbmessage = json.getString("message");
            System.out.println( "message: " + fbmessage );

i am getting the output in json format but i am unable to read the message , getting error at this line JSONObject json = new JSONObject(inputLine);
getting nullpointer exception . below is my log

01-28 14:05:56.384: E/FBUtils(5894): getPostId
01-28 14:05:56.384: E/FBUtils(5894): java.lang.NullPointerException
01-28 14:05:56.384: E/FBUtils(5894):    at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
01-28 14:05:56.384: E/FBUtils(5894):    at org.json.JSONTokener.nextValue(JSONTokener.java:94)
01-28 14:05:56.384: E/FBUtils(5894):    at org.json.JSONObject.<init>(JSONObject.java:154)
01-28 14:05:56.384: E/FBUtils(5894):    at org.json.JSONObject.<init>(JSONObject.java:171)
01-28 14:05:56.384: E/FBUtils(5894):    at org.appright.myneighborhood.utils.FBUtils.doInBackground(FBUtils.java:104)
01-28 14:05:56.384: E/FBUtils(5894):    at org.appright.myneighborhood.utils.FBUtils.doInBackground(FBUtils.java:1)

Any help is appreciated.

  • 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-06-18T00:27:10+00:00Added an answer on June 18, 2026 at 12:27 am

    use StringBuilder instead of String for reading data from InputStream and try as to read data from InputStream:

    StringBuilder inputLine = new StringBuilder();
    String s;
    String NL = System.getProperty("line.separator");
    while ((s = in.readLine()) != null) {
       inputLine.append(s + NL);
    }
    in.close();
    JSONObject json = new JSONObject(inputLine.toString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to retrieve data using the new graph API, however the token I'm
I am trying out odata4j in my android app to retrieve data from a
I'm a bit new to android and I'm trying to retrieve some data from
I am trying to retrieve some data from the Google Maps API from a
I am trying to use TouchJSON to retrieve data from a php page with
I am trying to use a textreader to retrieve data from a text file
I get the error Warning: file_get_contents(https://graph.facebook.com/me?fields=id,name,picture) [function.file-get-contents]: failed to open stream: HTTP request failed!
I am trying retrieve data from a .php file on a server from within
I am trying to retrieve an image from SQL Server (yes, data type is
I'm wondering why can't I open my app. Plus, I'm trying to retrieve data

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.