Download a Webpage Java Program

By | June 8, 2016

Java Program To Download A Webpage using Command Line

Learn How To Write a Java Program To Download A Webpage using Command Line Arguments on the Console Screen. This Code To Download a Website Page in Java makes use of Advanced Java Programming concepts. The java.net package plays a very important role in the code.

This Java Code To Fetch the Webpage saves the webpage in an HTML format in a text file. It, therefore, helps you to Save a Webpage for Offline Reading.

How To Enter Command Line Arguments

Syntax
java class_name complete_url file_name

Example
java DownloadWebpage https://www.codingalpha.com CodingAlpha

The First Argument needs to be have the complete URL of the Webpage to be downloaded. It has to even the HTTP or HTTPS. The Second URL is used for saving the webpage in the system. Therefore, you can give it a name along with its extension such as .HTML, .HTM, .TXT and many others. The default extension is .HTML.

 

Also Read: Java Program To Take User Input using Scanner Class

Code To Download Website in Advanced Java Programming

 

Also Read: How To Connect C and Java for Java Network Interface

Output

Advanced Java Tutorial To Download a Webpage in Java using Command Line Arguments

If you have any Compilation Error or Doubt about this Java Program To Download A Webpage, let us know about it in the Comment Section below.

2 thoughts on “Download a Webpage Java Program

  1. Pankaj Dhende

    Such an amazing program! Thanks! Now, I can download and save webpages for offline reading! 😀

    Reply

Let's Discuss