Load and Parse HTML file using JSoup

If you want to parse the html file from your local disk you can use the static Jsoup.parse(File in, String charsetName) or Jsoup.parse(File in, String charsetName, String baseUri) method. Also you can manipulate the html content.

If an error occurs while loading the file, it will throw an IOException. baseUri parameter is used by the parser to resolve relative URLs in the document ( relative url in href tag). You can also pass empty string if you are not concern about baseUri.

Another method parse(File in, String charsetName) also use to parse html file from you file system, which uses the file’s location as the baseUri.


package com.ehowtonow.jsoup;

import java.io.File;
import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class JSoupParseHTML {

	public static void main(String[] args) {

		try {
			File htmlFileinput = new File("C:\\ehowtonow\\jsoup.html");
			Document htmlDocument = Jsoup.parse(htmlFileinput, "UTF-8");
		} catch (IOException e) {



How to parse HTML String using JSoup – eHowToNow – JSoup

Ask your questions in eHowToNow Forum

Post your technical, non-technical doubts, questions in our site. Get answer as soon as possible, meanwhile you can help others by answering, unanswered questions.
To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

  1. JSoup DOM methods
  2. Load and Parse HTML file using JSoup
  3. Load and Parse HTML from url using JSoup
  4. How to parse HTML String using JSoup
  5. JSoup to parse body fragment
  6. JSOUP HTML Parser Introduction

Be the first to comment

Leave a Reply