Java FileOutputStream Create getOutputStream(String fname, String enc, boolean append)

Here you can find the source of getOutputStream(String fname, String enc, boolean append)

Description

Caller is responsible for write flush, close, etc.

License

Apache License

Parameter

Parameter Description
fname file path
enc encoding
append true = append data to existing file.

Exception

Parameter Description
IOException an exception

Declaration

public static OutputStreamWriter getOutputStream(String fname, String enc, boolean append) throws IOException 

Method Source Code

//package com.java2s;
/**//  w ww . j  av a  2  s  . co m
 *
 *  Copyright 2009-2013 The MITRE Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * **************************************************************************
 *                          NOTICE
 * This software was produced for the U. S. Government under Contract No.
 * W15P7T-12-C-F600, and is subject to the Rights in Noncommercial Computer
 * Software and Noncommercial Computer Software Documentation Clause
 * 252.227-7014 (JUN 1995)
 *
 * (c) 2012 The MITRE Corporation. All Rights Reserved.
 * **************************************************************************
 */

import java.io.*;

public class Main {
    /** Caller is responsible for write flush, close, etc.
     * @param fname file path
     * @param enc encoding
     * @param append  true = append data to existing file.
     * @return 
     * @throws IOException  
     */
    public static OutputStreamWriter getOutputStream(String fname, String enc, boolean append) throws IOException {
        return new OutputStreamWriter(new FileOutputStream(fname, append), enc);
    }

    /** Caller is responsible for write flush, close, etc.
     * @param fname 
     * @param enc
     * @return 
     * @throws IOException  
     */
    public static OutputStreamWriter getOutputStream(String fname, String enc) throws IOException {
        return getOutputStream(fname, enc, false);
    }
}

Related

  1. getOutputStream(String file)
  2. getOutputStream(String filename)
  3. getOutputStream(String fileName)
  4. getOutputStream(String filename, Map map)
  5. getOutputStream(String filename, String dir)
  6. getOutputStream(String path)
  7. getOutputStream(String path)
  8. getOutputStream(String root, String name, boolean overwrite, boolean verbose)
  9. getOutputStream(String theFilePath)