• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to save the directory structure to ArrayList ?

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello people,

i want to know how save the directory structure to ArrayList, and then later i can iterate it, so that the double path or the double string remove and then i will zip the directory with the ZipOutputStream class (of course i give the path to FileInputStream and write it to ZipOutputStream). Which one is better : ArrayList, TreeSet, Vector, List, etc from Collection class ? Can someone give an example how to figure it, any help would be appreciated ?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you'll find you can walk the directory structure and write the files in a single path rather than walk it once to get directory names and walk those to write files. Have you looked at all the methods on File? You'll need a recursive routine something like:

That's not real Java of course ... let me know if it is close enough to get you started coding.
 
benny rusli
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello people,

thanks for replaying my question, i want to save the path of directory to List Collection because i want to avoid the double entry name such as c:\java\example.txt could occur two time if i zip a large of directory and file(more than 2 GB). And the second reason i want to obtain the directory structure. Have anyone better solution than i have gotten, here is my code :



Another solution would be appreciated.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic