• Post Reply Bookmark Topic Watch Topic
  • New Topic

can you help me?  RSS feed

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have written a method which zip a folder which only contains multiple files but when there is sub folder within that folder my code breaks, so i have written this method
which list the entire files in a directory by recursive call but still this code fails to achieve what i want
output of this code is just a folder with the name like if i specify to zip a "abc " folder and the destination name would be "abc.zip" i get a "folder" named "abc.zip"

can any one help me ?

 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the future, please UseAMeaningfulSubjectLine(⇐click) so people will know at a glance what your question is about and can then easily decide whether they're interested in pursuing it.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be easier to understand what you're trying to do if you gave your method a meaningful name. I think what you're trying to do (but I'm not sure) is zip up an entire directory structure--including files and subdirectories--into a single zip file. Is that right?

If this is what you're trying to do, then why are you creating a new output file for each input file you encounter?

If this is not what you're trying to do, please explain it more clearly.
 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand correctly, you want a File named "abc.zip." But what is really happening is that a Folder named "abc.zip" is being created, not a File.

The reason for this is line 10:

This method specifically makes the a Folder (or directory) with the name you provide it. Instead, if you want to make sure all the folders in which the abc.zip file is supposed to be stored are made, then you should do:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!