• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Downloading a Directory

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
<code>
File f1=new File(dirname);
String s[]=f1.list();
int i;
for (i=0;i<s.length;i++)
{
byte[] buf=new byte[4 * 1024];
buf=s[i].getBytes();
out.write(buf);

}
</code>
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.


 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the following code to work:
for (int i=0;i<s.length;i++)
{
out.println(s[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).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic