File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Problem with ZipInputStream ......... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Problem with ZipInputStream ........." Watch "Problem with ZipInputStream ........." New topic
Author

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

Mukti Bajaj
Ranch Hand

Joined: Dec 11, 2000
Posts: 59
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.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
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).]


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Mukti Bajaj
Ranch Hand

Joined: Dec 11, 2000
Posts: 59
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with ZipInputStream .........