• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic