001package org.kuali.ole.loaders.common;
002
003import org.apache.log4j.Logger;
004import org.springframework.core.io.ClassPathResource;
005import org.springframework.core.io.Resource;
006
007import java.io.*;
008import java.net.URI;
009
010/**
011 * Created by sheiksalahudeenm on 3/5/15.
012 */
013public class FileUtils {
014
015    private static final Logger LOG = Logger.getLogger(FileUtils.class);
016
017    public static String readFileContent(String path) throws IOException {
018        BufferedReader br=new BufferedReader(new FileReader(getFilePath(path)));
019        String line=null;
020        String fullContent = "";
021        while ((line=br.readLine())!=null)
022        {
023            fullContent += line;
024        }
025        return fullContent;
026    }
027
028    public static String getFilePath(String classpathRelativePath)  {
029        try {
030            Resource rsrc = new ClassPathResource(classpathRelativePath);
031            return rsrc.getFile().getAbsolutePath();
032        } catch(Exception e){
033            LOG.error("Error : while accessing file "+e);
034        }
035        return null;
036    }
037}