String html = Jsoup.connect("www.example.com").get().html();
Scanner in = new Scanner(html);
String links ;
while(in.hasNext()){
String line = in.nextLine();
if(line.contains("sometext")){
String links += line.substring(line.indexOf("http").line.indexOf("</a>") + "\n");
}
I have the above code. It gets the HTML of a webpage using JSoup and after that, I want to save them to a string or to an array separated by new line. That’s my problem.
You should kept using jsoup for the retrieving and parsing the HTML. Also, jsoup’s documentation address this.