Here you can find the source of saveDocumentToDirectory(final org.jsoup.nodes.Document doc, final String fileName, final Path tmpDir)
private static Path saveDocumentToDirectory(final org.jsoup.nodes.Document doc, final String fileName, final Path tmpDir) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.OutputStream; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; public class Main { private static final Charset ENCODING_UTF8 = StandardCharsets.UTF_8; private static Path saveDocumentToDirectory(final org.jsoup.nodes.Document doc, final String fileName, final Path tmpDir) throws IOException { final Path outTmpPath = tmpDir.resolve(fileName); writeAll(outTmpPath, doc.outerHtml(), ENCODING_UTF8); return outTmpPath; }/*from w w w . j a va 2 s .co m*/ private static void writeAll(Path path, String data, Charset cs) throws IOException { try (OutputStream os = Files.newOutputStream(path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) { os.write(data.getBytes(ENCODING_UTF8)); } } }