I have a dynamic text file that picks content from a database according to the user’s query. I have to write this content into a text file and zip it in a folder in a servlet. How should I do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Look at this example:
This will create a zip in the root of
D:namedtest.zipwhich will contain one single file calledmytext.txt. Of course you can add more zip entries and also specify a subdirectory like this:You can find more information about compression with Java here.