• 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

errors in compression & release

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the program for compression & uncompression using GZIP....


import java.io.*;
import java.util.zip.*;
public class Gzippin {

public static void main(String[] args) {
// TODO code application logic here
String inStr = "Department of Information and Communication Technology";

ByteArrayOutputStream baos = new ByteArrayInputStream();
GZIPOutputStream gos = new GZIPInputStream(baos);


PrintWriter pw=new PrintWriter(gos);
pw.print(inStr);
pw.close();

byte [] bar = baos.toByteArray();
System.out.println (new String(bar));

ByteArrayInputStream bais= new ByteArrayInputStream(bar);
GZIPInputStream gis= new GZIPInputStream(bais);
byte [] buffer= new byte[1024];
if (gis.available() > 0)
gis.read(buffer,0,1024);
System.out.println(new String(buffer));

if (buffer.equals(inStr))
System.out.println("Compressed and Uncompressed strings are EQUAL");
}



}


This gives me two errors when I exected in Net beans IDE...

C:\Documents and Settings\Administrator\JavaApplication2\src\javaapplication2\Gzippin.java:9: cannot find symbol
symbol : constructor ByteArrayInputStream()
location: class java.io.ByteArrayInputStream
ByteArrayOutputStream baos = new ByteArrayInputStream();

C:\Documents and Settings\Administrator\JavaApplication2\src\javaapplication2\Gzippin.java:10: cannot find symbol
symbol : constructor GZIPInputStream(java.io.ByteArrayOutputStream)
location: class java.util.zip.GZIPInputStream
GZIPOutputStream gos = new GZIPInputStream(baos);

Thanks in advance for ur answers....

- I S
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yout got what look like some bad cut-and-paste errors here. You're creating new XXXInputStreams, and assigning them to variables of type XXXOutputStream; in the process, you're using constructors that the InputStream classes don't have. Just look at the error messages carefully, and you'll see the problem.
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic