wood burning stoves
The moose likes Servlets and the fly likes Downloading a Directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Downloading a Directory" Watch "Downloading a Directory" New topic

Downloading a Directory

Sumit Israni

Joined: Jun 20, 2001
Posts: 28
Hi All,
Could anyone please help me resolve this problem :I want to download an entire directory .I am using the com.oreilly.servlet package .I am utilizing the ServletUtils class in it.Following is the code in it which I want to modify in order to download an entire directory/folder.Of course in the returnFile() method I am passing a Directory name rather than just a file name.
File f1=new File(dirname);
String s[]=f1.list();
int i;
for (i=0;i<s.length;i++)
byte[] buf=new byte[4 * 1024];

I am getting a bit stuck in the above code as to how to output an array of bytes(the array contains the filenames in the directory as obtained by the list() method.) to the output stream.
Any help will be much appreciated.Thanks a lot.

ben rowe

Joined: Aug 16, 2001
Posts: 5
I got the following code to work:
for (int i=0;i<s.length;i++)
I'm assuming out is ServletOutputStream and since that is a character writer I don't know why you think you have to be working with bytes.

[This message has been edited by ben rowe (edited September 03, 2001).]
[This message has been edited by ben rowe (edited September 03, 2001).]
I agree. Here's the link: http://aspose.com/file-tools
subject: Downloading a Directory
It's not a secret anymore!