This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mukti Bajaj
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Mukti Bajaj
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic