package io.compgen.common.io;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;

public class FileUtils {
	public FileUtils() {
	}
    public static OutputStream openOutputStream(String outputName) throws IOException {
    	if (outputName == null || outputName.equals("-")) {
            return System.out;
        } else if (outputName.endsWith(".gz")) {
            return new GZIPOutputStream(new FileOutputStream(outputName));
        } else {
            return new BufferedOutputStream(new FileOutputStream(outputName));
        }
    }

}

@@ -329,16 +329,213 @@
 ption %7B%0A
+    %09return openOutputStream(outputName, false);%0A    %7D%0A%0A    public static OutputStream openOutputStream(String outputName, boolean forceCompress) throws IOException %7B%0A    %09if (forceCompress) %7B%0A    
     %09if 
@@ -595,23 +595,48 @@
         
+  
+  
 return 
+new GZIPOutputStream(
 System.o
@@ -637,18 +637,238 @@
 stem.out
+)
 ;%0A
+            %7D else %7B%0A                return new GZIPOutputStream(new FileOutputStream(outputName));%0A            %7D%0A    %09%7D else %7B%0A%09    %09if (outputName == null %7C%7C outputName.equals(%22-%22)) %7B%0A%09            return System.out;%0A%09
         
@@ -904,24 +904,25 @@
 h(%22.gz%22)) %7B%0A
+%09
             
@@ -976,32 +976,33 @@
 m(outputName));%0A
+%09
         %7D else %7B
@@ -994,32 +994,33 @@
        %7D else %7B%0A
+%09
             retu
@@ -1074,32 +1074,33 @@
 m(outputName));%0A
+%09
         %7D%0A    %7D%0A
@@ -1089,21 +1089,28 @@
 %0A%09        %7D%0A
+    %09%7D%0A
     %7D%0A%0A%7D%0A

add an option to force compression and not just rely on the file suffix