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
indexOfreturns an int, which represents the last index of the substring in the whole string. Use this index to withString#substring()get a sub-string of the original:The use of
lastIndexOfis pretty much the same: