Java Programming Idea GZIP (Zip) format compression decompression

Source: Internet
Author: User

OutputStream object, cannot accept writer object, will be garbled in Chinese
Gzipinputstream  supports reader character streams
1  Packageio;2 3 ImportJava.io.BufferedOutputStream;4 ImportJava.io.BufferedReader;5 ImportJava.io.FileInputStream;6 Importjava.io.FileNotFoundException;7 ImportJava.io.FileOutputStream;8 ImportJava.io.FileReader;9 Importjava.io.IOException;Ten ImportJava.io.InputStreamReader; One ImportJava.util.zip.GZIPInputStream; A ImportJava.util.zip.GZIPOutputStream; -  -  Public classgzipcompress { the      -      -      Public Static voidMain (string[] args)throwsIOException { -String fileName = "Src\\io\\gzipcompress.java"; +BufferedReader in =NewBufferedReader (NewFileReader (FileName)); -          +Bufferedoutputstream out =NewBufferedoutputstream ( A                                         NewGzipoutputstream ( at                                                 NewFileOutputStream ("test.gz")) -                                         ); -          -System.out.println ("Write File"); -         intC; -          in          while((c = In.read ())! = 1) { - Out.write (c); to}//Gzipoutputstream only supports byte objects, one write (Chinese garbled) +  - in.close (); the out.close (); *          $         //-------------------Read--------------Panax NotoginsengSYSTEM.OUT.PRINTLN ("Read File"); -          theBufferedReader in2 =NewBufferedReader ( +                 NewInputStreamReader (NewGzipinputstream ( A                                 NewFileInputStream ("test.gz")))); the         //support for character objects + String S; -          while((s = in2.readline ())! =NULL ) { $ System.out.println (s); $         } -          -          the          -     }Wuyi      the      -      Wu      -  About}

Results and document structure

Java Programming Idea GZIP (Zip) format compression decompression

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.