package in.gov.digilocker.uidai.web.validator;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WriteStringToFile {    
	
	private static final Logger logger = LoggerFactory.getLogger(WriteStringToFile.class);
	
	public static void writeToFile(String data) throws IOException {
		String fileSeparator = System.getProperty("file.separator");
        String absoluteFilePath = fileSeparator+"Users"+fileSeparator+"speed"+fileSeparator+"file.txt";
        File file = new File(absoluteFilePath);
        if(file.createNewFile()){
            System.out.println(absoluteFilePath+" File Created");
        }else System.out.println("File "+absoluteFilePath+" already exists");        
        	//file name only
        	file = new File("file.txt");
        	if(file.createNewFile()){
        		System.out.println("file.txt File Created in Project root directory");
        	}else {
        		System.out.println("File file.txt already exists in the project root directory");
        	}        
    		//relative path
    		String relativePath = "tmp"+fileSeparator+"file.txt";
    		file = new File(relativePath);
        	if(file.createNewFile()){
        			System.out.println(relativePath+" File Created in Project root directory");
        	}else System.out.println("File "+relativePath+" already exists in the project root directory");
    	}
	
	public static void writeToFile1(String data) throws IOException {
		File file = new File("rajivvvvvvvvv.txt");
		logger.info("FilePath------------------" +file.getAbsolutePath());
		FileWriter fileWriter = new FileWriter(file);
		fileWriter.write(data);		
		fileWriter.flush();
		fileWriter.close();		
	}		
        
        
	
	

}