Jsoup Example: print title of an url

Jsoup example: print title of an url tutorial for beginners and professionals, jsoup - java html parser providing facility to parse html document by java language with examples of printing title, links, images, form elements from url.

Jsoup Example: print title of an url

Jsoup Example: print title of an url

Let's see the jsoup example to print title of an url e.g. www.javatpoint.com. By the help of Jsoup.connect() method, we will connect with the URL. The get() method returns the reference of Document object. The document class provides title() method that returns the title of the document.

  1. import java.io.IOException;  
  2. import org.jsoup.Jsoup;  
  3. import org.jsoup.nodes.Document;  
  4. public class FirstJsoupExample{  
  5.     public static void main( String[] args ) throws IOException{  
  6.                 Document doc = Jsoup.connect("http://www.samttpoint.com").get();  
  7.                 String title = doc.title();  
  8.                 System.out.println("title is: " + title);  
  9.     }  
  10. }  

Output:

title is: hpnmaratt - A Solution of all Technology