00001 package edu.tum.cs.util; 00002 import java.io.File; 00003 import java.io.FileNotFoundException; 00004 import java.io.FileReader; 00005 import java.io.IOException; 00006 00007 public class FileUtil { 00008 00009 public static String readTextFile(File file) throws FileNotFoundException, IOException { 00010 FileReader fr = new FileReader(file); 00011 char[] cbuf = new char[(int)file.length()]; 00012 fr.read(cbuf); 00013 String content = new String(cbuf); 00014 fr.close(); 00015 return content; 00016 } 00017 00018 public static String readTextFile(String filename) throws FileNotFoundException, IOException { 00019 return readTextFile(new File(filename)); 00020 } 00021 00022 }