File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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

Dinesh Jayaraj
Greenhorn

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
import java.io.*;
import java.net.*;
class zipfold
{
public static void main(String args[])
{
String url=null;
String userid=null;
String passwd=null;

try
{
BufferedReader bo=new BufferedReader(new InputStreamReader(System.in));
System.out.println("entet the userid");
userid=bo.readLine();
System.out.println("entet the password");
passwd=bo.readLine();
System.out.println("entet the url");
url=bo.readLine();
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()];
b=line.getBytes();
fo.write(b);
}
}catch(Exception e){System.out.println(e);}
} //function main
} //class

------------------
Carl Trusiak
Sheriff

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
Greenhorn

Joined: Nov 22, 2000
Posts: 3
You can try the FtpBean component at the following address.
I used it already it it works perfectly.
www.geocities.com/SiliconValley/Code/9129/javabean/ftpbean
Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
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