Java FileOutputStream Create getOutputStream(String filename)

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

Description

Gets an output stream

License

Apache License

Declaration

public static OutputStream getOutputStream(String filename) 

Method Source Code

//package com.java2s;
/*//  w  w  w . j av  a  2s  .  co m
 * Copyright 2004 Senunkan Shinryuu
 *
 * 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.
 */

import java.io.*;

public class Main {
    /** Gets an output stream */
    public static OutputStream getOutputStream(String filename) {
        OutputStream os = null;
        try {
            File f = new File(filename);
            os = new FileOutputStream(f);
        } catch (Exception e) {
            try {
                os.close();
            } catch (Exception ex) {
            }
            os = null;
        }
        return os;
    }
}

Related

  1. getOutputStream(File file, String filePath)
  2. getOutputStream(final File file)
  3. getOutputStream(final File file)
  4. getOutputStream(final Object obj, final boolean append)
  5. getOutputStream(String file)
  6. getOutputStream(String fileName)
  7. getOutputStream(String filename, Map map)
  8. getOutputStream(String filename, String dir)
  9. getOutputStream(String fname, String enc, boolean append)