Java File to OutputStream openOutputStream(String outputName)

Here you can find the source of openOutputStream(String outputName)

Description

open Output Stream

License

Open Source License

Declaration

public static OutputStream openOutputStream(String outputName) throws IOException 

Method Source Code


//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));
        }
    }
}

Related

  1. openOutputStream(File file)
  2. openOutputStream(File file)
  3. openOutputStream(File file, boolean append, boolean gzip)
  4. openOutputStream(File file, int bufferSize)
  5. openOutputStream(String filePath)
  6. outStream(final File aFile)
  7. outStream(String file)