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

com.relevantcodes.extentreports.utils.Writer Maven / Gradle / Ivy

There is a newer version: 2.41.2
Show newest version
/*
* Copyright (c) 2015, Anshoo Arora (Relevant Codes).  All rights reserved.
* 
* Copyrights licensed under the New BSD License.
* 
* See the accompanying LICENSE file for terms.
*/

package com.relevantcodes.extentreports.utils;

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

public class Writer {
    public synchronized void write(final File f, String text) {
    	BufferedWriter writer = null;
    	
        try {
            writer = new BufferedWriter(new FileWriter(f));
            writer.write(text);
        } 
        catch (Exception e) {
            e.printStackTrace();
        } 
        finally {
            try {
              writer.close();
            } 
            catch (Exception e) {
            	e.printStackTrace();
            }
        }
    }
    
    private Writer() { }
	
	private static class Instance {
        static final Writer INSTANCE = new Writer();
    }
	
	public static Writer getInstance() {
		return Instance.INSTANCE;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy