View Javadoc

1   package org.kuali.ole.ingest;
2   
3   import java.io.BufferedReader;
4   import java.io.File;
5   import java.io.FileReader;
6   import java.io.IOException;
7   
8   /**
9    * FileUtil will reads the given file and returns stringBuilder
10   */
11  public class FileUtil {
12      /**
13       *  This method reads the mentioned file and returns stringBuilder
14       * @param file
15       * @return  stringBuilder
16       * @throws IOException
17       */
18      public String readFile(File file) throws IOException {
19          BufferedReader reader = new BufferedReader(new FileReader(file));
20          String line = null;
21          StringBuilder stringBuilder = new StringBuilder();
22          String ls = System.getProperty("line.separator");
23          while ((line = reader.readLine()) != null) {
24              stringBuilder.append(line);
25              stringBuilder.append(ls);
26          }
27          return stringBuilder.toString();
28      }
29  }