Java Files copy from InputStream
import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URI; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void main(String[] args) { // //from w w w.j ava 2 s . c o m Path newFile = FileSystems.getDefault().getPath("Site.html"); URI url = URI.create("https://demo2s.com/"); try (InputStream inputStream = url.toURL().openStream()) { Files.copy(inputStream, newFile); System.out.println("Site copied successfully!"); } catch (MalformedURLException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } } }