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 6733731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:48:14+00:00 2026-05-26T10:48:14+00:00

sorry for the stupid question but my knowledge of java net is terrible. BAsically

  • 0

sorry for the stupid question but my knowledge of java net is terrible.
BAsically in my android application a call many php scripts to get data from a mysql db.
These data are returned in json format and i use Google json library to parse them.
Everything works fine but know in each php page i have to add a test. It the test is successfull, then the script continues and returns the json file, but if the test fails, the script return the string “false”, or the value false (that’s up to me) and my application instead of showing data has to redirect the user to a login page.

The code is the following:

        URL url = new URL(Costanti.IP_SERVER+"myApps.php"+"?userId="+this.userId);
        try 
        {

            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            int status = conn.getResponseCode();
            if (status >= 200 && status <= 299)
            {
                Reader r = new InputStreamReader(conn.getInputStream());
                Applicazioni dati = new Applicazioni();
                try 
                {

                    dati = gsonReader.fromJson(r, Applicazioni.class);

                    return dati;
                } 
                catch (Exception e) 
                {
                    System.out.println("Ho fallito a prendere i dati");
                    Log.e("JSON_Parser",e.toString());

                }
            }   
        } 
        catch (IOException e) 
        {
            System.out.println("Ho fallito la connnection");
            e.printStackTrace();
        }
    } 

So basically i use this google library to read the json file inside the imputStreamReader and fill the Applicazioni object with my data.

How can i check if the content of the imputStreamReader is the string “false” or the boolean false and if it’s different parse it with the json library????

In the php at the end i do
echo json_encode($applicazione);
in one case or
echo “false” in the other case
Tnx

  • 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-26T10:48:15+00:00Added an answer on May 26, 2026 at 10:48 am
    InputStream in = new URL(url).openStream();
    Scanner scanner = new Scanner(new InputStreamReader(in));
    String result = scanner.useDelimiter("\\Z").next(); // this reads the whole
                                                        // script output in a string
    if(result.equals("false"))
     handle the false value...
    else
      dati = gsonReader.fromJson(result, Applicazioni.class);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for the stupid question, but this is driving me crazy... I have test_framework.php
I'm trying to learn Java so sorry if this is a stupid question, but
Really stupid question, sorry, but I can't find it on google (I'm sure it's
Sorry if this sounds like a really stupid question, but I need to make
I am sorry, my question is stupid, but I am not able to answer
Sorry if this is a stupid question... I've developed an application that creates absolute
hello there and sorry for the stupid question but i think i might be
I'm really sorry. This must seem like an incredibly stupid question, but unless I
Sorry if this seems like a stupid question but im actually having a hard
Sorry if this is a silly and/or stupid question but... Will there ever be,

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.