All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aventstack.extentreports.io.BufferedWriterWriter Maven / Gradle / Ivy

The newest version!
package com.aventstack.extentreports.io;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.logging.Level;
import java.util.logging.Logger;

public class BufferedWriterWriter {

    private static class WriterInstance {
        static final BufferedWriterWriter INSTANCE = new BufferedWriterWriter();

        private WriterInstance() {
        }
    }

    static final Logger logger = Logger.getLogger(BufferedWriterWriter.class.getName());

    private BufferedWriterWriter() {
    }

    public synchronized void write(final File f, String text) {
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) {
            writer.write(text);
        } catch (Exception e) {
            logger.log(Level.SEVERE, f.getPath(), e);
        }
    }

    public static BufferedWriterWriter getInstance() {
        return WriterInstance.INSTANCE;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy