import java.nio.channels.*; import java.net.*; import java.io.*; public class DownloadFile { public static void main(String args[]) throws Exception{ URL website = new URL("http://courses.coreservlets.com/Course-Materials/pdf/struts/01-Struts-Intro.pdf"); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); FileOutputStream fos = new FileOutputStream("structs.pdf"); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); fos.close(); rbc.close(); } }
This blog is primarily focus on Java fundamentals and the libraries built on top of Java programming language. Most of the post are example oriented, hope you have fun in reading my blog....:)
Friday, 1 August 2014
Download file from Internet using Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment