How to read and write a zip file in java?
<p>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.</p>

<p><strong>I am able read zip file with this code:</strong></p>

<pre><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();
</code></pre>

<p><strong>And, i am also able make a text file to zip with this code:</strong></p>

<pre><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();
</code></pre>

<p>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.</p>

<p>Any Suggestions!!</p>
