File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes downloading zip files from a site to local disk(urgent please) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "downloading zip files from a site to local disk(urgent please)" Watch "downloading zip files from a site to local disk(urgent please)" New topic

downloading zip files from a site to local disk(urgent please)

Dinesh Jayaraj

Joined: Nov 19, 2000
Posts: 23
hello friends:
iam doing a project in java networking.
iam connecting to a site(http or ftp) having userid and password.
code for this is given below,and i want to download the
files in that site to the local disk, but that site contains zip file,i want to download that zip file as it is to the local disk creating a file folder in the local disk.
how it can be done?
help urgently please
class zipfold
public static void main(String args[])
String url=null;
String userid=null;
String passwd=null;

BufferedReader bo=new BufferedReader(new InputStreamReader(;
System.out.println("entet the userid");
System.out.println("entet the password");
System.out.println("entet the url");
URL u=new URL(url);
String compress= userid+":"+passwd;
String encoding=new sun.misc.BASE64Encoder().encode(compress.getBytes());
URLConnection uc= u.openConnection();
uc.setRequestProperty("Authorization","Basic "+encoding);
InputStream content = (InputStream)uc.getInputStream();
BufferedReader in = new BufferedReader (new InputStreamReader (content));
String line;
FileOutputStream fo=new FileOutputStream("c:/dinesh1/springer.html");
while ((line = in.readLine()) != null) {
System.out.println (line);
byte b[]=new byte[line.length()];
}catch(Exception e){System.out.println(e);}
} //function main
} //class

Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
Jeff Holmes was kind enough to donate an ftp client implementation using sockets. This should meet your needs.
Hope this helps

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Eric Lafargue

Joined: Nov 22, 2000
Posts: 3
You can try the FtpBean component at the following address.
I used it already it it works perfectly.
I agree. Here's the link:
subject: downloading zip files from a site to local disk(urgent please)
Similar Threads
url connection: IOException-socket closed
Writing data into file from URL address
How to read html file?
problem with ZipInputStream
problem in using zipinputstream class