Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java Zip 2

Status
Not open for further replies.

GGROD

Programmer
Feb 7, 2002
68
US
Can anyone explain how I would use the java.util.zip class to zip a file I have. I would like to zip the file after I write it to the directory.
Here is some sample code I have to write a file:

File file = new File(webPath+filename);

FileWriter fileWrite = new FileWriter(file);

String outputString = new String();
outputString += "Text here";
outputString += "and here";

fileWrite.write(outputString);
fileWrite.flush();
fileWrite.close();
 
Look at the ZipOutputStream or Deflater classes, and use them as you would any other IO stream.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top