1 package org.kuali.ole.loaders.common;
2
3 import org.apache.log4j.Logger;
4 import org.springframework.core.io.ClassPathResource;
5 import org.springframework.core.io.Resource;
6
7 import java.io.*;
8 import java.net.URI;
9
10
11
12
13 public class FileUtils {
14
15 private static final Logger LOG = Logger.getLogger(FileUtils.class);
16
17 public static String readFileContent(String path) throws IOException {
18 BufferedReader br=new BufferedReader(new FileReader(getFilePath(path)));
19 String line=null;
20 String fullContent = "";
21 while ((line=br.readLine())!=null)
22 {
23 fullContent += line;
24 }
25 return fullContent;
26 }
27
28 public static String getFilePath(String classpathRelativePath) {
29 try {
30 Resource rsrc = new ClassPathResource(classpathRelativePath);
31 return rsrc.getFile().getAbsolutePath();
32 } catch(Exception e){
33 LOG.error("Error : while accessing file "+e);
34 }
35 return null;
36 }
37 }