wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes can't zip my files using zipentry and zipinputstream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "can Watch "can New topic
Author

can't zip my files using zipentry and zipinputstream

prabhat g
Greenhorn

Joined: Feb 04, 2001
Posts: 5
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).]


formul
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
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).]


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
prabhat g
Greenhorn

Joined: Feb 04, 2001
Posts: 5
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

Joined: Feb 04, 2001
Posts: 5
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

Joined: Jun 13, 2000
Posts: 3340
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
 
 
subject: can't zip my files using zipentry and zipinputstream