Java ZipOutputStream Create getOutputStream(String outputFileName)

Here you can find the source of getOutputStream(String outputFileName)

Description

get Output Stream

License

Open Source License

Declaration

public static OutputStream getOutputStream(String outputFileName) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

import java.util.zip.GZIPOutputStream;

public class Main {
    public static OutputStream getOutputStream(String outputFileName) throws IOException {
        if ("stdout".equals(outputFileName)) {
            return System.out;
        } else if ("stderr".equals(outputFileName)) {
            return System.err;
        } else if (outputFileName.endsWith(".gz")) {
            OutputStream out = new FileOutputStream(outputFileName);
            return new GZIPOutputStream(out);
        } else {//from   ww  w  .ja  v  a 2 s .c  o  m
            return new FileOutputStream(outputFileName);
        }
    }
}

Related

  1. getOutputStream(File file)
  2. getOutputStream(File file, boolean append)
  3. getOutputStream(File tarFile)