privatestaticStringembed(FilehtmlFile){Stringfinal_return="error";try{BufferedReaderbr=newBufferedReader(newFileReader(htmlFile));StringBuildersb=newStringBuilder();Stringline="";while((line=br.readLine())!=null){sb.append(line);}br.close();StringhtmlContent=sb.toString();org.jsoup.nodes.Documentdoc=Jsoup.parse(htmlContent);Elementsimages=doc.getElementsByTag("img");for(Elementimage:images){StringimgName=image.attr("src");// we surppose image files are in the same folder with the html file.FiletempImageFile=newFile(file.getParentFile().getAbsoluteFile()+"/"+imgName);if(tempImageFile.exists()&&imgName.trim()!=""){StringimageString=newString(Base64.encodeBase64(FileUtils.readFileToByteArray(tempImageFile)));image.attr("src","data:image;base64,"+imageString);}else{// if the image file not exist, just put a empty string in it or leave it as it wasimage.attr("src","data:image;base64,"+"");}}final_return=doc.toString();}catch(Exceptione){//do stuff...}returnfinal_return;}