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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:26:08+00:00 2026-06-05T10:26:08+00:00

I have the following code in an Android application: public static HttpResponse dbPost(String handlerUrl,

  • 0

I have the following code in an Android application:

public static HttpResponse dbPost(String handlerUrl, List<NameValuePair> postData) {

    HttpClient httpclient = new DefaultHttpClient();
    String postUrl = constants.postUrl(); 
    HttpPost httppost = new HttpPost(postUrl);
    HttpResponse response = null;
    System.out.print("Catch 0");

    try {
        httppost.setEntity(new UrlEncodedFormEntity(postData));
        response = httpclient.execute(httppost);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.print("Catch 1");

    return response;

}

I have a button that calls this block. If I press the button, the console will print “Catch 0” (but NOT “Catch 1”). If I press the button again (same instance), the console will print “Catch1Catch0”. What’s the problem?

I’m a bit new to Java so bear with me.

  • 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-05T10:26:09+00:00Added an answer on June 5, 2026 at 10:26 am

    You need to call flush since you’re using print.

    System.out.print("Catch 1");
    System.out.flush();
    

    The default behavior of PrintStream is to only flush when a newline is written. (This behavior is documented in write(int).)

    If you used printLn instead of print, the stream would flush automatically. Without that, you need to explicitly flush the output stream.

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

Sidebar

Related Questions

in Android, I have list that I fill using the following code @Override public
I have created an ExpandableListView with the following code: <ExpandableListView android:id=@+id/android:list android:layout_width=wrap_content android:layout_height=0dp android:layout_marginTop=5dp
I have the following code for Android which works fine to play a sound
I have the following code as my Android.mk in my project/jni folder. folder libA
How I can add Header params in restlet android? I have following code: ClientResource
I have the following code running on my Android device. It works great and
I have the following code in a WCF Service that returns a string, and
The application will run fine unless I add the following code. public class TFView
I my application I have written following code in order to extract phone number.
I have a very basic ASP MVC application exposing a static list of publications

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.