Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

Get Title From URL


Let’s see the jsoup example to print title of an url e.g. www.Kreationnext.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.Kreationnext.com”).get();
  7.                 String title = doc.title();
  8.                 System.out.println(“title is: ” + title);
  9.     }
  10. }

Output:

Comments

comments