Downloading a File in an Applet or Application

Write a java application or applet that downloads a file from across the network. Due to security considerations, applets may only download files on the server from which they were downloaded. To download a file, you must construct the URL location as an instance of the URL class. With the URL class in hand, you can invoke the openConnection() method to retrieve an instance of the URLConnection class. From here there are two options: Added Sophistication:

Script to run the Download demo


References

Flanagan, David; Java in a Nutshell, Section 7 on Networking
The Java tutorial is a useful online resource, especially the chapters on networking overview and working with URLs.
Look at the Javasoft Java API Documentation on the java.net package.