public void copyNetFile() throws IOException, URISyntaxException {
String pathname="D:"+File.separator+"threadDumps";
File file=new File(pathname);
File[] files = file.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isFile();
}
});
assert files.length>0;
URIBuilder ub=new URIBuilder("https://www.runoob.com/try/try.php?filename=vue2-js-expr");
HttpGet get = new HttpGet(ub.build());
String fileName=ub.getQueryParams().get(0).getValue();
fileName+=".html";
file=files[0];
boolean b = files[0].renameTo(new File(pathname + File.separator + fileName));
assert b;
pathname="D:"+File.separator+"inetpub"+File.separator+"wwwroot";
b=file.renameTo(new File(pathname + File.separator + fileName));
HttpClient httpClient = new DefaultHttpClient();
HttpResponse httpResponse = httpClient.execute(get);
if (httpResponse.getStatusLine().getStatusCode() == 200) {
HttpEntity entity = httpResponse.getEntity();
String html= EntityUtils.toString(entity);
pathname=pathname + File.separator + fileName;
OutputStream os=new FileOutputStream(pathname);
Document document = Jsoup.parse(html);
Elements elements = document.select("textarea");
html=elements.html();
html=html.replace("<","<").replace(">",">");
os.write(html.getBytes());
os.close();
}
}