Skip to main content

Uncompress GZip file


package com.pukhraj.blog;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.zip.GZIPInputStream;

public class UncompressGZip {
  public static void main(String[] argv) throws Exception {
    String source = "path/FileName.gzip";
    GZIPInputStream in = new GZIPInputStream(new FileInputStream(source));
    String target = "path/outfilename";
    OutputStream out = new FileOutputStream(target);
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
      out.write(buf, 0, len);
    }
    in.close();
    out.close();
  }
}

Comments

Popular posts from this blog

Common Eclipse Shortcuts for Java Developer Open Resource : ctrl+shift+r Quick Outline : ctrl+o Assign to local variable : ctrl+2, L Rename : alt+shift+r  Extract Local Variable : alt+shift+l  Extract Method : alt+shift+m

Replace Non ASCII Characters in a File

Replace Non ASCII Characters in a File ? package com.pukhraj.blog; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; public class ReplaceNonAsciiCharacters {     public static void main(String args[]) {         String inputFileName = "D:/input_file_name.txt";         String outputFileName = "D:/output_file_name.txt";         try {         // Read the content from the input file using BufferedReader object.             BufferedReader in = new BufferedReader(new FileReader(inputFileName));                         // Write the content to the output file using BufferedWriter object.             BufferedWriter out = new BufferedWriter(new FileWriter(outputFileName));         ...