• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't zip my files using zipentry and zipinputstream

 
prabhat g
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the source code for my filezipper class to zip files.
but it runs till s.o.p(" line48")and doesn't continue.I get my frame along with the filechoser window .Even the file zipfile.zip is created but remains a null file of 0 bytes.any one to help me.

Edit with ubb code tags for clarity
[This message has been edited by Carl Trusiak (edited February 06, 2001).]
 
Carl Trusiak
Sheriff
Posts: 3340
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You never initialize the String[] inputfilenames and when you try to add to it at inputfilenames[j]=inputfiles[j].getPath(); it throws a null pointer exception change the code
String[] inputfilenames=null;
File[] inputfiles=chooser.getSelectedFiles();
To:
File[] inputfiles=chooser.getSelectedFiles();
String[] inputfilenames= new String[inputfiles.length];
And it'll work fine.
Do your self a big favor! NEVER have an empty catch block. If you would have had something as simple as

it would have made debugging easier!
==========================================
Please Read and Following ourNaming Policy It can benefit you read Book Giveaway

[This message has been edited by Carl Trusiak (edited February 06, 2001).]
 
prabhat g
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot Carl.
well ,that was really a silly mistake by me or may be i couldn't figure it out that time.I am trying to explore the various capabilities of java .I may trouble u a little more sometime later.
Thanking u
 
prabhat g
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i did the necessary changes you suggested .I got a zipexception
saying "there must be atleast one entry in the zipoutputstream"
also that before this the FileChooser.getSelectedFiles() method
returns a null array of type File[].Is there some problem with my JFileChooser instance and code therein.I get this Exception on clicking the open button of JFileChooser Component.Please help me .
 
Carl Trusiak
Sheriff
Posts: 3340
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a Naming Policy If you wish to continue with us, please register with a proper name that meets the requirements. People who do not will have their accounts blocked.
I am looking forward to your posts
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic