This program to zip file not working. Where is the error.

I have the following code which does'nt zips the file. Where is the error, and can any1 rectify that.
I am running on command prompt.
Assuming that a.txt and b.txt exists in that folder.
TestZip.java
searchsanjaysharmaAsked:
Who is Participating?
 
mccarlConnect With a Mentor IT Business Systems Analyst / Software DeveloperCommented:
Ahh, yeah, you will need all the correct import statements. Replace the import that you have (at the top of your file) with this...

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

Open in new window

(Better to explicitly import each class, it's a good habit to get into that will help you when writing more complex programs)
0
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
What error are you getting? It runs fine for me, zips the files correctly!
0
 
searchsanjaysharmaAuthor Commented:
Error is attached.
error.docx
0
 
searchsanjaysharmaAuthor Commented:
Good
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.