Java FileOutputStream Create getOutputStreamForFile(String filename)

Here you can find the source of getOutputStreamForFile(String filename)

Description

get Output Stream For File

License

Open Source License

Declaration

public static OutputStream getOutputStreamForFile(String filename) 

Method Source Code


//package com.java2s;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class Main {
    public static OutputStream getOutputStreamForFile(String filename) {
        try {/* w w w. ja v a2  s. c  om*/
            File file = new File(filename);
            if (!file.exists()) {
                file.createNewFile();
            }
            return new FileOutputStream(file);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }
}

Related

  1. getOutputStream(String path)
  2. getOutputStream(String path)
  3. getOutputStream(String root, String name, boolean overwrite, boolean verbose)
  4. getOutputStream(String theFilePath)
  5. getOutputStreamForFile(final File file)
  6. writeFile(File outFile, ZipInputStream zipInputStream, ZipEntry entry)
  7. writeFile(FileOutputStream fileoutputstream, byte abyte0[], int i)
  8. writeFile(final String filename, final byte[] data)
  9. writeFile(final String fileNamePath, final byte[] daten)