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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:51:01+00:00 2026-05-26T23:51:01+00:00

I have an HTML source code in one String . I want to get

  • 0

I have an HTML source code in one String. I want to get a part of string using indexOf and lastIndexOf, but I only get integer

textView.setText("");
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
// Get the response

ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response_str = client.execute(request, responseHandler);

//response_str.lastIndexOf("morning—the sixth day.");
textView.setText( response_str.indexOf("<div class='commentary-link'>"););

I want to get a part of HTML code, and don’t know how to do that.

thanks all

  • 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-26T23:51:02+00:00Added an answer on May 26, 2026 at 11:51 pm

    indexOf returns an int, which represents the last index of the substring in the whole string. Use this index to with String#substring() get a sub-string of the original:

    int index =  response_str.indexOf("<div class='commentary-link'>");
    textView.setText( response_str.substring(index));
    

    The use of lastIndexOf is pretty much the same:

    int index =  response_str.lastIndexOf("<div class='commentary-link'>");
    textView.setText( response_str.substring(index));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some HTML errors in my output source code, coming from one of
I have a PDF that is being generated from HTML source using HTMLDOC. While
I have a text area in which users can type source code (html/css/js). I
I have C# code that creates HTML. One particular piece of code creates a
My code just creates inline-diff (on a per-word basis) of a string using HTML
I have a txt file which actually is a html source of some webpage.
I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a>
I have HTML code edited by FCKEditor stored in a database and would like
I have html code like this <tr class=odd> <td><b>Reason for Termination:</b></td> <td>this has bunch

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.