Java BufferedWriter Create getBufferedWriter(File f)

Here you can find the source of getBufferedWriter(File f)

Description

get Buffered Writer

License

Open Source License

Declaration

public static BufferedWriter getBufferedWriter(File f) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.HashMap;

public class Main {
    public static HashMap<File, BufferedWriter> writers = new HashMap<File, BufferedWriter>();

    public static BufferedWriter getBufferedWriter(File f) {
        try {/*from w w  w .  j a v  a  2s .  co m*/
            if (writers.containsKey(f)) {
                return writers.get(f);
            } else {
                BufferedWriter returns = new BufferedWriter(new FileWriter(f, true));
                writers.put(f, returns);
                return returns;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. getBufferedWriter(File file)
  2. getBufferedWriter(final Writer out)
  3. getBufferedWriter(OutputStream os)
  4. getBufferedWriter(String directory, String filename)