How can I download and save a file from the Internet using Java?

There is an online file (such as http://www.example.com/information.asp) I need to grab and save to a directory. I know there are several methods for grabbing and reading online files (URLs) line-by-line, but is there a way to just download and save the file using Java?

23 Answers
23

Use Apache Commons IO. It is just one line of code:

FileUtils.copyURLToFile(URL, File)

Leave a Comment