Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3391050
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:45:40+00:00 2026-05-18T03:45:40+00:00

I am doing a practice to understand read and write zip files in java.

  • 0

I am doing a practice to understand read and write zip files in java. I’d read about reading a file and making it to zip file, and i have also tried. I’d read about reading a zip file using java. How can i combine this read and write operations together. Like, i want to read a zipped file in HDD and i want to save it in a another location.

I am able read zip file with this code:

FileInputStream fs = new FileInputStream("C:/Documents and Settings/tamilvendhank/Desktop/abc.zip");
ZipInputStream zis = new ZipInputStream(fs);
ZipEntry zE;
while((zE=zis.getNextEntry())!=null){
    System.out.println(ze.getName());
    zis.closeEntry();
  }

zis.close();

And, i am also able make a text file to zip with this code:

String fn = "C:/Documents and Settings/tamilvendhank/Desktop/New Text Document.txt";
byte[] b = new byte[1024];
FileInputStream fis = new FileInputStream(fn);
fis.read(b, 0, b.length);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream("C:/Documents and Settings/tamilvendhank/Desktop/123.zip"));
ZipEntry ze = new ZipEntry(fn);
ze.setSize((long)b.length);
zos.setLevel(6);
zos.putNextEntry(ze);
zos.write(b, 0, b.length);
zos.finish();
zos.close();

Now how i shall connect the above two codes and make the code to read a zip file and write it in a different location.

Any Suggestions!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:45:40+00:00Added an answer on May 18, 2026 at 3:45 am

    Why don’t you open it up as a FileInputStream and dump the contents over into a FileOutputStream. This is how a simple copy operation is performed, you don’t have to unzip the file and then zip it back on another location on HDD.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to remove/delete a migration file. How would I go about doing
When doing thread synchronization in C# should I also lock an object when I
When doing an ALTER TABLE statement in MySQL, the whole table is read-locked (allowing
I've read a lot about Mercurial and branching in it, however, I am still
I recently read a jQuery tutorial about best practices. I usually run all my
I'm doing something different but this is an easier to understand example. Think of
Doing odd/even styling with jQuery is pretty easy: $(function() { $(.oddeven tbody tr:odd).addClass(odd); $(.oddeven
When doing an INSERT with a lot of data, ie: INSERT INTO table (mediumtext_field)
When doing small icons, header graphics and the like for websites, is it better
When doing case-insensitive comparisons, is it more efficient to convert the string to upper

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.