Here you can find the source of getOutputStreamForFile(String filename)
public static OutputStream getOutputStreamForFile(String filename)
//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); } } }