Blame | Last modification | View Log | RSS feed
/****/package in.shop2020.serving.utils;import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStreamReader;import org.apache.log4j.Logger;/*** Utility functions** @author rajveer**/public class FileUtils {private static Logger log = Logger.getLogger(Class.class);public static String read(String filename) throws IOException {File f = new File(filename);if(!f.exists()) {throw new FileNotFoundException(filename + " - does not exist");}StringBuilder textString = new StringBuilder();FileInputStream fis = null;try {fis = new FileInputStream(f);BufferedReader br = new BufferedReader(new InputStreamReader(fis));String line;while((line = br.readLine()) != null){textString.append(line+"\n");}} finally {if(fis != null)fis.close();}log.debug("Reading " + filename + " completed");return textString.toString();}/**** @param filename* @throws Exception*/public static boolean delete(String filename) throws Exception {File f = new File(filename);if(f.exists()) {return f.delete();}return true;}}