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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:53:04+00:00 2026-05-25T11:53:04+00:00

I’m trying to get the HttpPost result from server and converting it into byte

  • 0

I’m trying to get the HttpPost result from server and converting it into byte array and get the the specific bytes from byte[]. For now I’m using this code and it’s working. I need to change it to what I want to do. Here is the code :

public class UserLogin extends Activity {

    Button cancel,login;
    HttpClient httpclient;
    HttpPost httppost;
    ArrayList<NameValuePair> postParameters;
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        httpclient = new DefaultHttpClient();
        httppost = new HttpPost("http://www.rpc.test.com");

        postParameters = new ArrayList<NameValuePair>();
        //postParameters.add(new BasicNameValuePair("new_auth_data","1"));
        postParameters.add(new BasicNameValuePair("username_hash", "c34a6cf6bff9f6b61e96fdf4bf360157d522a17c"));
        postParameters.add(new BasicNameValuePair("password_hash", "56dc55f0062cf21797637b0f8652293023f2ef22"));

        cancel = (Button) findViewById(R.id.cancel_login_btn);
        cancel.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                finish();
            }
        });

        login = (Button) findViewById(R.id.login_btn);
        login.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                try {
                    httppost.setEntity(new UrlEncodedFormEntity(postParameters));

                    HttpResponse response = httpclient.execute(httppost);
                    Log.d("Login", "Response " + response.getEntity());

                    String responseBody = EntityUtils.toString(response.getEntity());
                    byte[] b = responseBody.getBytes();
                    // here




                    new AlertDialog.Builder( UserLogin.this )
                    .setTitle( "Warning" )
                    .setMessage( responseBody )
                    .setPositiveButton( "Ok", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            Log.d("AlertDialog", "Positive");
                        }
                    })
                    .show();

                } catch (Exception e) {
                    Log.d("ERROR"," Error lol - "+e);
                }

            }
        });
    }
}

As a result of this HttpPost I’m getting a string which I need to convert to byte as I did and get the specific bytes from it..Like to start from 15 element to 25 or something like this. Any suggestions how can I do that?

Thanks in advance for all suggestions and help.

  • 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-25T11:53:05+00:00Added an answer on May 25, 2026 at 11:53 am

    extracting a subarray from an array is done with arrayCopy http://developer.android.com/reference/java/lang/System.html#arraycopy%28java.lang.Object,%20int,%20java.lang.Object,%20int,%20int%29

    for elements 15 to 25:

    byte[] subarray = new byte[25-15];
    System.arrayCopy(b, 15, subarray, 0, subarray.length);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back 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
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

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.