Forums Register Login

Problem with ZipInputStream .........

+Pie Number of slices to send: Send
Hi friends,
import java.io.*;
import java.util.zip.*;
public class ReadCompressedPrimes
{
public static void main(String[] args)
{
try
{
FormatWriter out = new FormatWriter(
new BufferedWriter(
new FileWrite(FileDescriptor.out)));
String dirName = "C:/data/mukti/java1";
String zipName = "NewPrimes.zip";
File myPrimeZip = new File(dirName,zipName);
ZipOutputStream myZipFile =new ZipOutputStream
(new FileOutputStream(myPrimeZip));
ZipEntry myZipEntry = myZipFile.getNextEntry();
DataOutputStream primesIn = new DataOutputStream(
new BufferedOutputStream(myZipFile));
long [] primes = new long[6];
boolean EOF = false;
while(!EOF)
{
int index = 0;
try
{
for(index=0;index<primes.length;index++)>
primes[index]=primesIn.readLong();
}
catch(EOFException e)
{
EOF = true;
}
for(int j=0;j<index;j++)>
out.print(primes[j]);
out.println();
}
out.close();
primesIn.close();
}
catch(FileNotFoundException e)
{
System.err.println(e);
return;
}
catch(IOException e)
{
System.err.println("Error reading input file" + e);
return;
}
}
}
The code written above when complied gives error...
C:\Data\Mukti\Java\ReadCompressedPrimes.java:25: cannot resolve symbol
symbol : method getNextEntry ()
location: class java.util.zip.ZipOutputStream
ZipEntry myZipEntry = myZipFile.getNextEntry();
^
C:\Data\Mukti\Java\ReadCompressedPrimes.java:40: cannot resolve symbol
symbol : method readLong ()
location: class java.io.DataOutputStream
primes[index]=primesIn.readLong();
^
Please can someone help me.....
Thanks.
+Pie Number of slices to send: Send
You have to open a ZipFile Object in order to create a ZipInputStream not a File Object.
See the example here http://www.javaranch.com/ubb/Forum34/HTML/000343.html
Hope this helps

[This message has been edited by Carl Trusiak (edited December 21, 2000).]
+Pie Number of slices to send: Send
Hi Carl,
I am sorry, but I am not able to understand........can you please clarify in detail.I hope you don't mind.
Thanks.
Let's go to the waterfront with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1677 times.
Similar Threads
"write end dead" or "pipe" broken error
Losing newlines in text file when zipping
Problem zipping the file
how to put two different folders(which is in different location) into one zip entry
how to zip multiple files and directory into one output
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:53:22.