Here you can find the source of openOutputStream(String outputName)
public static OutputStream openOutputStream(String outputName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.zip.GZIPOutputStream; public class Main { 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 {/*from w ww.ja va 2 s . com*/ return new BufferedOutputStream(new FileOutputStream(outputName)); } } }