Save a webpage using JAVA
import java.io.InputStream; import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class DownloadWebpage { public static void main(String[] args) { Path path = Paths.get("PATH TO SAVE WEB PAGE"); // Eg: /home/devan/google URI u = URI.create("https://www.google.co.in/"); try (InputStream in = u.toURL().openStream()) { Files.copy(in, path); } catch (Exception e) { e.printStackTrace(); } } }
No comments:
Post a Comment