I expect this is pretty basic:
When downloading pages from a Chinese website, all Chinese characters appear as "?" in the saved file (viw java NIO Files.write).
I know the Chinese webpage is retrieved as UTF-8 (page.getPageEncoding() returns "UTF-8"), but something goes wrong in my saving of the webpage.
My code is as follows:
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_45);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setTimeout(15000);
final HtmlPage page = webClient.getPage(urlNow);
pageAsXml = page.asXml();
NioLog.getLogger().debug(page.getPageEncoding());
Files.write(Paths.get(outputPath + File.separator + fileNameTruncated + TXT), pageAsXml.getBytes());
The answer is as follows: